473,883 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'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 24351

<sq********@yah oo.com> wrote in message
news:10******** ************@c1 3g2000cwb.googl egroups.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(doub le d = 0);
~Conversion();

double getData(void);

void setResult(doubl e 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.l earn.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
2266
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 override. Lots of classes derive from FtNode, often through further base classes, eg. HTMLDirectoryElement --> HTMLElement --> Element --> FtNode There are many leaf classes like HTMLDirectoryElement. The problem
1
4207
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
678
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 classes. On the main cpp file. I have #include "hw6a.h" #include "hw6b.h"
1
2412
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> #include "resource.h" typedef struct tagNODE
1
3535
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). That application is built by one company and its usage is to show functionality of their static libraries. Now I created dynamic link library CoreLibrary and I want to integrate it into this example. CoreLibrary worked properly with win32...
1
3614
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 class CCriticalSectionGuard ; class CCriticalSection
0
1723
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 for the code: namespace LDAPfunctions {
2
7117
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: http://bugs.php.net/bug.php?id=15233&edit=1 Second, here's my problem: i have a class defined. Inside that class are several LONG functions
10
4356
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 in Linux with GCC. pthread_cond_signal(&(receiverConf->receive_q_cond)); pthread_cond_destroy(&(receiverConf->receive_q_cond)); pthread_mutex_destroy(&(receiverConf->receive_q_lock)); Main.cpp:545: ISO C++ forbids declaration of ` ...
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9789
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11129
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9569
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5794
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.