Click here to Skip to main content
15,922,407 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Updating UI from thread Pin
Rajesh R Subramanian3-Sep-09 20:16
professionalRajesh R Subramanian3-Sep-09 20:16 
Questionbutton(visible&Enable) but CANNOT be pressed Pin
fitatc3-Sep-09 14:48
fitatc3-Sep-09 14:48 
AnswerRe: button(visible&Enable) but CANNOT be pressed Pin
Eric Haddan4-Sep-09 4:48
Eric Haddan4-Sep-09 4:48 
GeneralRe: button(visible&Enable) but CANNOT be pressed Pin
fitatc6-Sep-09 18:20
fitatc6-Sep-09 18:20 
Questionvector question Pin
RobJones3-Sep-09 11:50
RobJones3-Sep-09 11:50 
AnswerRe: vector question Pin
Nemanja Trifunovic3-Sep-09 12:08
Nemanja Trifunovic3-Sep-09 12:08 
GeneralRe: vector question Pin
RobJones3-Sep-09 12:12
RobJones3-Sep-09 12:12 
QuestionTemplates... they are nasty!! Pin
o.kauert3-Sep-09 11:43
o.kauert3-Sep-09 11:43 
Hi there,

I am using VS 2008 Standard and have a problem compiling the following small C++ code snippet:

template <typename ArrayElement>
class Array
{
public:
	virtual void split( Array<Array*> *result = 0) // see comments below
	{
		if( result != 0)
		{
			result->clear();
			// do something to generate the result...
		}
	}
	void clear()
	{
		// empty the array
	}
};

void main(void)
{
	Array<int> a;
	a.split(); // the result does not matter for this compiler problem demo
}


The code itself here does not do anything really useful as it has been simplified to demonstrate the nature of problem which occurs with my real Array implementation: the code does not compile!! And I really can't understand why?? Confused | :confused: Some kind of recursion in evaluating the template seems to happen here. BUT: Note the underlined "virtual" keyword in the code above. Leave this away and suddenly the code compiles?!? OMG | :OMG: This does not make sense to me - what has the successful compilation to do with "virtual" functions in this case??
For my "real" Array class I must be able to have all the member functions virtual to overrride them in derived classes. So the solution can't be to just leave the functions non-virtual. Additionally the data type shown here ( Array<Array*> ) for the restult of the "split" method shall not be changed as this data type seems to make a lot of sense in my mind. The returned data is also an array - an array of arrays to be exact.

So WTF can I do to make this work? Any help is really really appreciated Smile | :) Smile | :) Smile | :)

Thanks,
Oli
AnswerRe: Templates... they are nasty!! Pin
Nemanja Trifunovic3-Sep-09 12:20
Nemanja Trifunovic3-Sep-09 12:20 
AnswerRe: Templates... they are nasty!! [modified] Pin
Chris Losinger3-Sep-09 16:15
professionalChris Losinger3-Sep-09 16:15 
GeneralRe: Templates... they are nasty!! Pin
«_Superman_»3-Sep-09 17:41
professional«_Superman_»3-Sep-09 17:41 
GeneralRe: Templates... they are nasty!! Pin
o.kauert3-Sep-09 23:14
o.kauert3-Sep-09 23:14 
AnswerRe: Templates... they are nasty!! Pin
Stuart Dootson3-Sep-09 21:44
professionalStuart Dootson3-Sep-09 21:44 
GeneralRe: Templates... they are nasty!! Pin
o.kauert3-Sep-09 23:27
o.kauert3-Sep-09 23:27 
GeneralRe: Templates... they are nasty!! Pin
Stuart Dootson3-Sep-09 23:37
professionalStuart Dootson3-Sep-09 23:37 
GeneralRe: Templates... they are nasty!! Pin
o.kauert4-Sep-09 0:54
o.kauert4-Sep-09 0:54 
GeneralRe: Templates... they are nasty!! Pin
Stuart Dootson4-Sep-09 1:00
professionalStuart Dootson4-Sep-09 1:00 
GeneralRe: Templates... they are nasty!! Pin
o.kauert4-Sep-09 1:40
o.kauert4-Sep-09 1:40 
GeneralRe: Templates... they are nasty!! Pin
Stuart Dootson4-Sep-09 1:52
professionalStuart Dootson4-Sep-09 1:52 
QuestionPlaySound(MAKEINTRESOURCE, IDR_WAVE_RANDOM... problem Pin
lctrncs3-Sep-09 7:08
lctrncs3-Sep-09 7:08 
QuestionRe: PlaySound(MAKEINTRESOURCE, IDR_WAVE_RANDOM... problem Pin
David Crow3-Sep-09 7:18
David Crow3-Sep-09 7:18 
AnswerRe: PlaySound(MAKEINTRESOURCE, IDR_WAVE_RANDOM... problem Pin
lctrncs3-Sep-09 12:27
lctrncs3-Sep-09 12:27 
GeneralRe: PlaySound(MAKEINTRESOURCE, IDR_WAVE_RANDOM... problem Pin
David Crow3-Sep-09 18:15
David Crow3-Sep-09 18:15 
GeneralRe: PlaySound(MAKEINTRESOURCE, IDR_WAVE_RANDOM... problem Pin
lctrncs3-Sep-09 19:09
lctrncs3-Sep-09 19:09 
AnswerRe: PlaySound(MAKEINTRESOURCE, IDR_WAVE_RANDOM... problem Pin
iraclyKv3-Sep-09 22:58
iraclyKv3-Sep-09 22:58 

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.