Click here to Skip to main content
15,887,135 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionText file stream? Pin
supernalle6-Jun-06 19:16
supernalle6-Jun-06 19:16 
Questionask for suggestion Pin
cheng_guo6-Jun-06 19:00
cheng_guo6-Jun-06 19:00 
AnswerRe: ask for suggestion Pin
_AnsHUMAN_ 6-Jun-06 19:11
_AnsHUMAN_ 6-Jun-06 19:11 
GeneralRe: ask for suggestion Pin
cheng_guo7-Jun-06 5:24
cheng_guo7-Jun-06 5:24 
QuestionRe: ask for suggestion Pin
Hamid_RT6-Jun-06 19:33
Hamid_RT6-Jun-06 19:33 
QuestionWhich interface can I use to set background-repeat property? Pin
Tcpip20056-Jun-06 18:55
Tcpip20056-Jun-06 18:55 
AnswerRe: Which interface can I use to set background-repeat property? Pin
Tcpip20056-Jun-06 21:48
Tcpip20056-Jun-06 21:48 
QuestionAdding const won't compile Pin
MALDATA6-Jun-06 18:48
MALDATA6-Jun-06 18:48 
I'm trying to learn C++, so I'm just building some sample classes to get some experience. I have a matrix class in which I have implemented an addition operator that looks like this...

matrix operator + (matrix& toAdd)
{
// Create a zero matrix to output.
matrix output = matrix(toAdd.get_rows(), toAdd.get_cols(), 0);

// A temporary variable for the sum of each element
double val;

// Go through every element and add them together
// Stick the result in the output matrix
for(int i = 0; i < nrows; i++)
{
for(int j = 0; j < ncols; j++)
{
// The array indices are always 1 less
// than the row or column number
val = elements[i][j] + toAdd.get_el(i+1,j+1);
output.set_el(i+1, j+1, val);
}
}
return output;
}

It's nothing fancy... hopefully you won't need to see the whole class to understand the problem.

I wanted to pass it a matrix by reference in case the matrix is huge. I figure it'd probably be good form to add a const so that it is

matrix operator + (const matrix& toAdd)

but if I add that in, it doesn't compile. I get errors like

"passing 'const matrix' as 'this' argument of 'int matrix::get_rows()' discards qualifiers"

I get one of those errors for every time I use a member function of toAdd. Without const, everything's fine, but the matrix referred to as toAdd is vulnerable to changes. I am using gcc (or, more accurately, g++) to compile. Let me know if you need more information. Thanks!

-Mark
AnswerRe: Adding const won't compile Pin
sunit56-Jun-06 19:09
sunit56-Jun-06 19:09 
AnswerRe: Adding const won't compile Pin
toxcct6-Jun-06 22:00
toxcct6-Jun-06 22:00 
AnswerRe: Adding const won't compile Pin
Michael Dunn7-Jun-06 2:52
sitebuilderMichael Dunn7-Jun-06 2:52 
QuestionHow to clear the screen to recover to the old style Pin
xuwenq886-Jun-06 18:45
xuwenq886-Jun-06 18:45 
AnswerRe: How to clear the screen to recover to the old style Pin
Hamid_RT6-Jun-06 19:11
Hamid_RT6-Jun-06 19:11 
AnswerRe: How to clear the screen to recover to the old style [modified] Pin
Naveen6-Jun-06 21:50
Naveen6-Jun-06 21:50 
Generalbest book for VC++ beginners Pin
sach!!6-Jun-06 18:32
sach!!6-Jun-06 18:32 
GeneralRe: best book for VC++ beginners Pin
nicknotyet7-Jun-06 10:15
nicknotyet7-Jun-06 10:15 
GeneralRe: best book for VC++ beginners Pin
bob169727-Jun-06 17:46
bob169727-Jun-06 17:46 
GeneralRe: best book for VC++ beginners Pin
nicknotyet8-Jun-06 3:29
nicknotyet8-Jun-06 3:29 
GeneralRe: best book for VC++ beginners Pin
Nemanja Trifunovic7-Jun-06 15:18
Nemanja Trifunovic7-Jun-06 15:18 
GeneralRe: best book for VC++ beginners Pin
bob169727-Jun-06 17:46
bob169727-Jun-06 17:46 
GeneralRe: best book for VC++ beginners Pin
Krishnatv7-Jun-06 19:33
Krishnatv7-Jun-06 19:33 
GeneralRe: best book for VC++ beginners Pin
ThatsAlok7-Jun-06 19:43
ThatsAlok7-Jun-06 19:43 
QuestionXP/win2000 Scroller Click event Pin
anilksingh6-Jun-06 18:00
anilksingh6-Jun-06 18:00 
QuestionOpen Forms in a second Monitor Pin
spy_charly6-Jun-06 17:43
spy_charly6-Jun-06 17:43 
Question__LINE__ doesn't work in Visual Studio 2005 Pin
User 2155976-Jun-06 16:43
User 2155976-Jun-06 16:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.