Click here to Skip to main content
15,888,802 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: system phisycal drive Pin
«_Superman_»4-Feb-12 17:20
professional«_Superman_»4-Feb-12 17:20 
AnswerRe: system phisycal drive Pin
RomTibi14-Feb-12 17:57
RomTibi14-Feb-12 17:57 
QuestionSet window position Pin
_Flaviu4-Feb-12 5:34
_Flaviu4-Feb-12 5:34 
AnswerRe: Set window position Pin
Richard Andrew x644-Feb-12 10:57
professionalRichard Andrew x644-Feb-12 10:57 
GeneralRe: Set window position Pin
_Flaviu4-Feb-12 21:33
_Flaviu4-Feb-12 21:33 
AnswerRe: Set window position Pin
Chuck O'Toole5-Feb-12 4:57
Chuck O'Toole5-Feb-12 4:57 
GeneralRe: Set window position Pin
_Flaviu5-Feb-12 20:30
_Flaviu5-Feb-12 20:30 
QuestionGetter and setter style class implementation in VC++ Pin
Member 78851053-Feb-12 19:23
Member 78851053-Feb-12 19:23 
Dear all, I have a problem with implementing getter and setter type class in visual C++.
Hope somebody can help me. Let me first explain the detail of my code first.

I have 3 classes separated in .cpp and .h files
- SaveClass.cpp and SaveClass.h
= stores all variable values
- Class2.cpp and Class2.h
= call Set function of "SaveClass" class to set the value
- Class1.cpp and Class1.h
= call Get function of "SaveClass" class to get the value

the codes for three class are as follows:

1. SaveClass.h

class SaveClass
{
public:
SaveClass(void);
~SaveClass(void);
int Get() const;
int Set(int var);

private:
int testVariable;
};

2. SaveClass.cpp

#include "SaveClass.h"
SaveClass::SaveClass(void){testVariable = 1;}
SaveClass::~SaveClass(void){}
int SaveClass::Get() const{return testVariable;}
int SaveClass::Set(int var){
testVariable = var;
return testVariable;
}

3. Class2.h

class Class2
{
public:
Class2(void);
~Class2(void);
int function2(void);
};


4. Class2.cpp

#include "SaveClass.h"
int Class2::function2(void)
{
SaveClass coba;
int setNumber=2;
coba.Set(setNumber);

cout << "Value for Set : " << setNumber << endl;
return 0;
}


5. Class1.h

class Class1
{
public:
Class1(void);
~Class1(void);
void function1();
};

6. Class1.cpp

void Class1::function1()
{
SaveClass coba2;
int values = coba2.Get();
cout << "Value from Get : " << values << endl;
}

when I make new class (4th class) and call function2() and function1(), command window shows:

Value for Set : 2
Value from Get : 1

It suppose to be:

Value for Set : 2
Value from Get : 2

but from the result I got 2 and 1. My question is how can I make it correct (Value for Set : 2 and Value from Get : 2)? Thanks for all your help guys.
AnswerRe: Getter and setter style class implementation in VC++ Pin
Albert Holguin3-Feb-12 21:17
professionalAlbert Holguin3-Feb-12 21:17 
GeneralRe: Getter and setter style class implementation in VC++ Pin
Member 78851053-Feb-12 22:19
Member 78851053-Feb-12 22:19 
AnswerRe: Getter and setter style class implementation in VC++ Pin
Albert Holguin4-Feb-12 8:08
professionalAlbert Holguin4-Feb-12 8:08 
QuestionMessage for CASynsocket::OnConnect Pin
ForNow3-Feb-12 10:55
ForNow3-Feb-12 10:55 
AnswerRe: Message for CASynsocket::OnConnect Pin
Albert Holguin3-Feb-12 11:20
professionalAlbert Holguin3-Feb-12 11:20 
QuestionUpdating the color of child Window Pin
cpp_prgmer3-Feb-12 9:39
cpp_prgmer3-Feb-12 9:39 
AnswerRe: Updating the color of child Window Pin
Albert Holguin3-Feb-12 10:41
professionalAlbert Holguin3-Feb-12 10:41 
AnswerRe: Updating the color of child Window Pin
«_Superman_»3-Feb-12 15:32
professional«_Superman_»3-Feb-12 15:32 
QuestionHow to use DeviceIoControl to access an external USB device from MFC Pin
StefanKittel3-Feb-12 5:37
StefanKittel3-Feb-12 5:37 
AnswerRe: How to use DeviceIoControl to access an external USB device from MFC Pin
Erudite_Eric3-Feb-12 6:29
Erudite_Eric3-Feb-12 6:29 
GeneralRe: How to use DeviceIoControl to access an external USB device from MFC Pin
StefanKittel3-Feb-12 6:46
StefanKittel3-Feb-12 6:46 
GeneralRe: How to use DeviceIoControl to access an external USB device from MFC Pin
Erudite_Eric4-Feb-12 4:32
Erudite_Eric4-Feb-12 4:32 
GeneralRe: How to use DeviceIoControl to access an external USB device from MFC Pin
StefanKittel4-Feb-12 4:49
StefanKittel4-Feb-12 4:49 
GeneralRe: How to use DeviceIoControl to access an external USB device from MFC Pin
Erudite_Eric4-Feb-12 22:42
Erudite_Eric4-Feb-12 22:42 
GeneralRe: How to use DeviceIoControl to access an external USB device from MFC Pin
StefanKittel5-Feb-12 10:20
StefanKittel5-Feb-12 10:20 
SuggestionRe: How to use DeviceIoControl to access an external USB device from MFC Pin
David Crow5-Feb-12 17:02
David Crow5-Feb-12 17:02 
Question"InvalidateRect" leaves dirty on screen Pin
transoft3-Feb-12 3:59
transoft3-Feb-12 3:59 

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.