Click here to Skip to main content
15,894,017 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is there a ListCtrl like this? Pin
Rolf Kristensen5-Feb-11 10:43
Rolf Kristensen5-Feb-11 10:43 
QuestionChoosing libraries for video project Pin
Member 37348905-Feb-11 4:33
Member 37348905-Feb-11 4:33 
AnswerRe: Choosing libraries for video project Pin
Code-o-mat5-Feb-11 6:19
Code-o-mat5-Feb-11 6:19 
QuestionHow to display jpg image in the CView Pin
yu-jian4-Feb-11 22:30
yu-jian4-Feb-11 22:30 
AnswerRe: How to display jpg image in the CView Pin
Code-o-mat4-Feb-11 23:03
Code-o-mat4-Feb-11 23:03 
AnswerRe: How to display jpg image in the CView Pin
Niklas L6-Feb-11 11:49
Niklas L6-Feb-11 11:49 
Questionc++ classes :( [SOLVED] Pin
csrss4-Feb-11 22:23
csrss4-Feb-11 22:23 
AnswerRe: c++ classes :( Pin
Andrew Brock4-Feb-11 23:28
Andrew Brock4-Feb-11 23:28 
To declare a variable as static, you must define the variable in 1 and only 1 source file.

//xxx.h
class xxx {
	public:
		static int ddd;
	//other stuff
};

//xxx.cpp
int xxx::ddd = 0; //you should provide an initial value, but it isn't required


This solution only allows a single instance of the class xxx.

To be able to access a variable from another class instance the class pointer is required. You can push this into the child class when it is created.

class xxx {
protected:
	int x;
	int y;
private:
public:
	int ddd;
	class ccc {
	protected:
	private:
		xxx *m_pParent;
	public:
		int sad() {
			printf("%d\r\n", m_pParent->ddd);
			//the \r character is redundant in a console (although needed if the console is piped to a file or text box)
		}
		ccc(xxx *pParent) : m_pParent(pParent) {}
		~ccc(){}
	};
	xxx() {
		ddd = 0;
		x = 10;
		y = 11;
	}
	~xxx() {
		x = 0;
		y = 0;
	}
};


An even better solution would be to declare class ccc a friend of class xxx so so you can make the variable int ddd protected or private.
GeneralRe: c++ classes :( Pin
csrss5-Feb-11 0:28
csrss5-Feb-11 0:28 
AnswerRe: c++ classes :( [SOLVED] [modified] Pin
Stefan_Lang7-Feb-11 2:49
Stefan_Lang7-Feb-11 2:49 
QuestionHow can text formatting tool in EditBox? Pin
Le@rner4-Feb-11 19:37
Le@rner4-Feb-11 19:37 
AnswerRe: How can text formatting tool in EditBox? Pin
Andrew Brock4-Feb-11 20:04
Andrew Brock4-Feb-11 20:04 
Questionprogram whit c language Stepper Motor Control through Parallel Port. help Pin
saleheh4-Feb-11 19:10
saleheh4-Feb-11 19:10 
AnswerRe: program whit c language Stepper Motor Control through Parallel Port. help Pin
Andrew Brock4-Feb-11 19:56
Andrew Brock4-Feb-11 19:56 
GeneralRe: program whit c language Stepper Motor Control through Parallel Port. help Pin
saleheh4-Feb-11 21:15
saleheh4-Feb-11 21:15 
Questionc++ split fnction help Pin
ehsan161804-Feb-11 19:02
ehsan161804-Feb-11 19:02 
AnswerRe: c++ split fnction help REPOST Pin
Richard MacCutchan4-Feb-11 23:38
mveRichard MacCutchan4-Feb-11 23:38 
QuestionHow to add items to CListCtrl faster? Pin
includeh104-Feb-11 10:53
includeh104-Feb-11 10:53 
AnswerRe: How to add items to CListCtrl faster? Pin
Hans Dietrich4-Feb-11 11:24
mentorHans Dietrich4-Feb-11 11:24 
GeneralRe: How to add items to CListCtrl faster? Pin
Chris Meech4-Feb-11 12:16
Chris Meech4-Feb-11 12:16 
GeneralRe: How to add items to CListCtrl faster? Pin
includeh104-Feb-11 13:57
includeh104-Feb-11 13:57 
GeneralRe: How to add items to CListCtrl faster? Pin
Hans Dietrich4-Feb-11 14:25
mentorHans Dietrich4-Feb-11 14:25 
AnswerRe: How to add items to CListCtrl faster? Pin
User 74293384-Feb-11 11:56
professionalUser 74293384-Feb-11 11:56 
AnswerRe: How to add items to CListCtrl faster? Pin
Andrew Brock4-Feb-11 15:09
Andrew Brock4-Feb-11 15:09 
QuestionHow to Run a thread after the process exit Pin
pandit844-Feb-11 2:10
pandit844-Feb-11 2:10 

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.