472,362 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,362 software developers and data experts.

'class' type redefinition

Hi

I doing my c++ homework and stuck on error 'class' type redefinition.

I have 5 classes. First class is base class. The next two classes are
derived from the first class. The next two classes are derived from
previous two classes. On the main file, I have...

#include "hw6a.h"
#include "hw6b.h"
#include "hw6c.h"
#include "hw6d.h"
#include "hw6e.h"

I got error "'class' type redefinition". If I commented all except the
last one, then class in those class file doesnt recognize when I
initialize an object.

Here is the file.

Main file:
http://users3.ev1.net/~sonle/school/cpp/hw6.cpp

Base class:
http://users3.ev1.net/~sonle/school/cpp/hw6a.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6a.h

Other derived class:
http://users3.ev1.net/~sonle/school/cpp/hw6a.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6a.h
http://users3.ev1.net/~sonle/school/cpp/hw6b.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6b.h
http://users3.ev1.net/~sonle/school/cpp/hw6c.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6c.h
http://users3.ev1.net/~sonle/school/cpp/hw6d.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6d.h
http://users3.ev1.net/~sonle/school/cpp/hw6e.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6e.h
Can someone sheds some light.
Thank.
Son

Jul 22 '05 #1
1 24038

<sq********@yahoo.com> wrote in message
news:10********************@c13g2000cwb.googlegrou ps.com...
Hi

I doing my c++ homework and stuck on error 'class' type redefinition.

I have 5 classes. First class is base class. The next two classes are
derived from the first class. The next two classes are derived from
previous two classes. On the main file, I have...

#include "hw6a.h"
#include "hw6b.h"
#include "hw6c.h"
#include "hw6d.h"
#include "hw6e.h"

I got error "'class' type redefinition". If I commented all except the
last one, then class in those class file doesnt recognize when I
initialize an object.

Here is the file.

Main file:
http://users3.ev1.net/~sonle/school/cpp/hw6.cpp

Base class:
http://users3.ev1.net/~sonle/school/cpp/hw6a.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6a.h

Other derived class:
http://users3.ev1.net/~sonle/school/cpp/hw6a.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6a.h
http://users3.ev1.net/~sonle/school/cpp/hw6b.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6b.h
http://users3.ev1.net/~sonle/school/cpp/hw6c.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6c.h
http://users3.ev1.net/~sonle/school/cpp/hw6d.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6d.h
http://users3.ev1.net/~sonle/school/cpp/hw6e.cpp
http://users3.ev1.net/~sonle/school/cpp/hw6e.h
Can someone sheds some light.

Look up "include guards".
// hw6a.h

#ifndef HW6A_H
#define HW6A_H

class Conversion
{
// friend ostream and istream
friend ostream &operator << (ostream&, Conversion &);
friend istream &operator >> (istream&, Conversion &);

private:
double data, result;

public:
Conversion(double d = 0);
~Conversion();

double getData(void);

void setResult(double d);
double getResult(void);

virtual void convert() = 0;
virtual void display() = 0;
};

#endif
Do this for all your header files.

-Mike

P.S. You also posted this to alt.comp.lang.learn.c-c++.
That's OK, your question is topical in both newsgroups,
but if you want to post to more than one group, do
a crosspost, don't post two separate messages.

-Mike
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John J. Lee | last post by:
I'm trying to change a base class of a big class hierarchy. The hierarchy in question is 4DOM (from PyXML). 4DOM has an FtNode class that defines __getattr__ and __setattr__ that I need to...
1
by: A | last post by:
Hi, I created an array of user defined objects dynamically in a class Foo's constructor. class Foo{ Foo(){ Bar* b = new Bar(); }
0
by: Son | last post by:
Hi I'm doing a C++ homework and stuck at one thing. I have 5 classes. First class is a base class. The next two are friend to first class. The next two classes are friend to previous two...
1
by: Bonj | last post by:
Hello I am trying to compile a dll with the below code used to search through an array of node structures. I am getting the following warning unfortunately: //wordsmain.c #include <windows.h>...
1
by: Alex | last post by:
Hello all, I have a very stupid problem that is driving me crazy...so plz if anyone ever saw this, I would like him to help me :) I have static MFC application in MSVC++ 6.0 (named Example)....
1
by: Martin.C.Johnsson | last post by:
Hi, I have the following problem The below class is fully defined in the header file thus there's no ..cpp-file. The header-file is included in several lib's I'm using. ---------- #pragma once...
0
by: =?Utf-8?B?Sm9obkE=?= | last post by:
When adding a "Managed Assembly" i.e., a dll to an existing C++/CLI program i get the error: LDAPfunctions.h(183) : error C2011: 'LDAPfunctions::LdapSsl' : 'class' type redefinition This is...
2
by: joe t. | last post by:
My apologies, i'm not sure how to ask this question correctly, so i'll give the examples as i go. First, i *think* my problem is described here, but i may be misunderstanding:...
10
by: tvnaidu | last post by:
I am using Three pthread functions below, I got ISO error, then I declared int variable called val123, then I assigned, but still I am getting error, any idea?. also I included pthread.h. compiling...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.