473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 24298

<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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.