473,320 Members | 2,083 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,320 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 24284

<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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.