 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
sharat Guest
|
Posted: Thu Apr 19, 2007 9:10 am Post subject: Compilation Error:Class name does not name a type. |
|
|
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
|
Posted: Thu Apr 19, 2007 9:10 am Post subject: Re: Compilation Error:Class name does not name a type. |
|
|
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
|
Posted: Thu Apr 19, 2007 9:10 am Post subject: Re: Compilation Error:Class name does not name a type. |
|
|
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
|
Posted: Thu Apr 19, 2007 9:10 am Post subject: Re: Compilation Error:Class name does not name a type. |
|
|
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 |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group
|