C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compilation Error:Class name does not name a type.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
sharat
Guest





PostPosted: Thu Apr 19, 2007 9:10 am    Post subject: Compilation Error:Class name does not name a type. Reply with quote



hi groups,

i have created 2 .cpp and .h(header) file and one main.cpp file, such
as file1.cpp and .h similarly file2.cpp & .h .
i have include the apropriate header files also .now i am creating the
object of class A (which is declare and define in file1.h) into class
B(which is declare and define in file2.h). i am getting an error that
"class a " doesnot name a type and the object i have creted is
undeclared . i am unable to get why this error is coming ,as i have
includede the related header files also.

can any body help to solve this problem.

Thanx in advance...
Back to top
sharat
Guest





PostPosted: Thu Apr 19, 2007 9:10 am    Post subject: Re: Compilation Error:Class name does not name a type. Reply with quote



here is my code ..

//file1.cpp
using namespace std;
#include "file1.h"
void plot_class::fun1()
{
cout<<"\n PLOT CLASS \n";
}

//file1.h
#ifndef FILE1_H
#define FILE_H

#include"file2.h"
class plot_class
{
public:
int p;
zone_class zone_obj;
void fun1();

};
#endif

similarly ,
//file2.cpp
#include"file2.h"
void zone_class ::fun_zone()
{
cout<<"\n zone class \n";
}

//file2.h
#ifndef FILE2_H
#define FILE2_H
#include"file1.cpp"

class zone_class
{
public:
int z;
plot_class plot_obj;
void fun_zone();
};
#endif

and main.cpp is as follows.

#include<iostream>
#include"file1.cpp"
#include"file2.cpp"
using namespace std;
int main()
{
cout<<"\n Hello World\n";
zone_class zone_obj1;

zone_obj1.fun_zone();

}

i am using gcc compiler ..after compiling i am getting the following
errors
$ g++ main.cpp


file2.h:9: error: 'plot_class' does not name a type
Back to top
Salt_Peter
Guest





PostPosted: Thu Apr 19, 2007 9:10 am    Post subject: Re: Compilation Error:Class name does not name a type. Reply with quote



On Apr 19, 2:28 am, sharat <aaliya.zar...@gmail.com> wrote:
Quote:
hi groups,

i have created 2 .cpp and .h(header) file and one main.cpp file, such
as file1.cpp and .h similarly file2.cpp & .h .
i have include the apropriate header files also .now i am creating the
object of class A (which is declare and define in file1.h) into class
B(which is declare and define in file2.h). i am getting an error that
"class a " doesnot name a type and the object i have creted is
undeclared . i am unable to get why this error is coming ,as i have
includede the related header files also.

can any body help to solve this problem.

Thanx in advance...


Not unless you show code.
Note that < class A > and < class a > do not correspond.
So the error is probably a fundamental one.
Back to top
Ian Collins
Guest





PostPosted: Thu Apr 19, 2007 9:10 am    Post subject: Re: Compilation Error:Class name does not name a type. Reply with quote

sharat wrote:
Quote:
hi groups,

i have created 2 .cpp and .h(header) file and one main.cpp file, such
as file1.cpp and .h similarly file2.cpp & .h .
i have include the apropriate header files also .now i am creating the
object of class A (which is declare and define in file1.h) into class
B(which is declare and define in file2.h). i am getting an error that
"class a " doesnot name a type and the object i have creted is
undeclared . i am unable to get why this error is coming ,as i have
includede the related header files also.

can any body help to solve this problem.

Please post a minimal example that gives your problem. Otherwise all

you can hope for is a guess.

--
Ian Collins.
Back to top
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
 


Powered by phpBB © 2001, 2006 phpBB Group