LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2012, 04:24 PM   #1
nontas.v
Member
 
Registered: Jan 2012
Posts: 32

Rep: Reputation: Disabled
ERROR: Class does not name a type


Well, I've got a project in my university. It's about a supermarket simulation programm.

There's a lot of code, I'll put only the one that matters.
Code:
template<class T>
class ChainNode {
	friend Chain<T>;
	private:
		//prive data
};

template<class T>
class Chain {
	public:
		//public data
	private:
		//private data
};
After trying to compile I get the error: "Chain does not name a type"

I tried also to initialize the Chain class at first but no results.

I'm still kinda newbie in c++, so I would appreciate some plain explanation.
Thanks
 
Old 04-28-2012, 04:32 PM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Hello, can you also post the code which actually generates the error? How do you create an instance of Chain?
 
Old 04-28-2012, 04:42 PM   #3
nontas.v
Member
 
Registered: Jan 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
In my main I do the following (according to my book): Chain<int> L; //L shows how many instances will be created

that's what you mean? :/
 
Old 04-28-2012, 04:49 PM   #4
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Is the file that contains the definition of the template in the same file where you use it or included in the file? The template must be defined in each compilation unit where you use it.
 
Old 04-28-2012, 04:51 PM   #5
nontas.v
Member
 
Registered: Jan 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
well I changed the " friend Chain<T>; " with " friend class Chain; " and it worked...thanks for your time anyway
 
Old 05-21-2012, 10:16 AM   #6
mitsosp
LQ Newbie
 
Registered: May 2012
Posts: 1

Rep: Reputation: Disabled
Eimai kai gw sto tmima s kai edw to idio provlima :/ .Ise sigouros oti ayto p ekanes doulevei? giati to vivlio to exei diaforetika.
 
Old 05-22-2012, 01:44 PM   #7
nontas.v
Member
 
Registered: Jan 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
sou stelnw pm
 
Old 05-22-2012, 01:45 PM   #8
nontas.v
Member
 
Registered: Jan 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
e-mail*
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error: expected constructor, destructor, or type conversion before class ilnli Programming 8 07-12-2011 09:32 PM
[SOLVED] C++ Initialize Class Member Variables of Another Class Type mirlin510 Programming 9 04-13-2011 11:46 AM
[SOLVED] Compilation error trying to sub-class a Qt QAction class, not sure why rstewart Programming 2 02-08-2011 11:45 AM
Non type class gregarion Programming 2 02-04-2010 03:16 PM
Identify class type Ephracis Programming 1 05-05-2007 09:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration