hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(int ialisation)
~Definition(); //destructor
//setter methods
void setDefinition(s tring);
void setNext(Definit ion*);
//getter Methods
string getDefinition() ;
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
*************** *************** *************** *************** *************** *************** *************** ***
//and the cpp file (Definition.cpp )
#include <iostream>
#include <string>
#include "Definition .h"
using namespace std;
Definition::Def inition()
{
definition.clea r();
next = NULL;
}
Definition::~De finition()
{
}
void Definition::set Definition(stri ng d)
{
definition = d;
}
void Definition::set Next(Definition * n)
{
next = n;
}
string Definition::get Definition()
{
return definition; //*****line 29******
}
Definition* Definition::get Definition()
{
return next; //*****line 34****
}
*************** *************** *************** *************** *************** *************** *************** ***
see the problem comes when i try to compile the Definition.cpp file. i
get the following erros
Definition.cpp: 34: error: prototype for `Definition*
Definition::get Definition()
' does not match any in class `Definition'
Definition.cpp: 29: error: candidate is: std::string
Definition::get Definition()
Definition.cpp: 34: error: `Definition* Definition::get Definition()'
and `std::st
ring Definition::get Definition()' cannot be overloaded
*************** *************** *************** *************** *************** *************** *************** ****
ive only done the linked list using integer data types, so i tried the
same coding for string. please forgive me if ive done any stupid
things in the coding.
please help me out
thanks! 6 1611
"djm" <dj*******@gmai l.comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.com.. .
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(int ialisation)
~Definition(); //destructor
//setter methods
void setDefinition(s tring);
void setNext(Definit ion*);
//getter Methods
string getDefinition() ;
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
*************** *************** *************** *************** *************** *************** *************** ***
//and the cpp file (Definition.cpp )
[SNIP]
string Definition::get Definition()
{
return definition; //*****line 29******
}
Definition* Definition::get Definition()
{
return next; //*****line 34****
}
You have 2 functions getDefinition both accepting no paramater. VC++
describes the problem a little differnent.
'Definition *Definition::ge tDefinition(voi d)' : overloaded function differs
only by return type from 'std::string Definition::get Definition(void )'
You can't overload a functioion only be return type. The parameters have to
be different. So maybe rename the 2nd one to:
Definition* Definition::get NextDefinition( )
then it would compile since you wouldn't be trying to overload the same
function name.
djm wrote:
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(int ialisation)
~Definition(); //destructor
//setter methods
void setDefinition(s tring);
void setNext(Definit ion*);
//getter Methods
string getDefinition() ;
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
*************** *************** *************** *************** *************** *************** *************** ***
//and the cpp file (Definition.cpp )
#include <iostream>
#include <string>
#include "Definition .h"
using namespace std;
Definition::Def inition()
{
definition.clea r();
next = NULL;
}
Definition::~De finition()
{
}
void Definition::set Definition(stri ng d)
{
definition = d;
}
void Definition::set Next(Definition * n)
{
next = n;
}
string Definition::get Definition()
{
return definition; //*****line 29******
}
Definition* Definition::get Definition()
Definition* Definition::get Next()
{
return next; //*****line 34****
}
On Oct 13, 12:55 pm, "Jim Langston" <tazmas...@rock etmail.comwrote :
"djm" <djmlog...@gmai l.comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.com.. .
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(int ialisation)
~Definition(); //destructor
//setter methods
void setDefinition(s tring);
void setNext(Definit ion*);
//getter Methods
string getDefinition() ;
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
*************** *************** *************** *************** *************** *************** *************** ***
//and the cpp file (Definition.cpp )
[SNIP]
string Definition::get Definition()
{
return definition; //*****line 29******
}
Definition* Definition::get Definition()
{
return next; //*****line 34****
}
You have 2 functions getDefinition both accepting no paramater. VC++
describes the problem a little differnent.
'Definition *Definition::ge tDefinition(voi d)' : overloaded function differs
only by return type from 'std::string Definition::get Definition(void )'
You can't overload a functioion only be return type. The parameters have to
be different. So maybe rename the 2nd one to:
Definition* Definition::get NextDefinition( )
then it would compile since you wouldn't be trying to overload the same
function name.
thanks Jim. i see the careless mistake ive done. now the program works
perfect..
thanks for your help. i really appreciate it.
On Oct 13, 1:16 pm, Barry <dhb2...@gmail. comwrote:
djm wrote:
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(int ialisation)
~Definition(); //destructor
//setter methods
void setDefinition(s tring);
void setNext(Definit ion*);
//getter Methods
string getDefinition() ;
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
*************** *************** *************** *************** *************** *************** *************** ***
//and the cpp file (Definition.cpp )
#include <iostream>
#include <string>
#include "Definition .h"
using namespace std;
Definition::Def inition()
{
definition.clea r();
next = NULL;
}
Definition::~De finition()
{
}
void Definition::set Definition(stri ng d)
{
definition = d;
}
void Definition::set Next(Definition * n)
{
next = n;
}
string Definition::get Definition()
{
return definition; //*****line 29******
}
Definition* Definition::get Definition()
Definition* Definition::get Next()
{
return next; //*****line 34****
}
thanks for pointing out the mistake.
the program compiles without any errors now. :D
On 2007-10-13 09:23, djm wrote:
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
Never use "using namespace std;" in a header-file, it will come back and
bite you with hard to diagnose errors later since ny file that includes
this header will then be influenced by the using directive.
class Definition
{
public:
Definition(); //constructor(int ialisation)
~Definition(); //destructor
//setter methods
void setDefinition(s tring);
void setNext(Definit ion*);
//getter Methods
string getDefinition() ;
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
*************** *************** *************** *************** *************** *************** *************** ***
//and the cpp file (Definition.cpp )
#include <iostream>
#include <string>
#include "Definition .h"
using namespace std;
Definition::Def inition()
{
definition.clea r();
You do not have to call clear, the string will be empty on creation.
next = NULL;
}
Definition::~De finition()
{
I do not know exactly how your liked list is supposed to work, but you
might want to have "delete next;" here to prevent any memory leaks.
}
void Definition::set Definition(stri ng d)
{
definition = d;
}
void Definition::set Next(Definition * n)
{
next = n;
What happens if next already points to some object? You might want to
"delete next;" before the assignment to prevent memory leaks.
}
string Definition::get Definition()
{
return definition; //*****line 29******
}
Definition* Definition::get Definition()
Definition* Definition::get Next()
{
return next; //*****line 34****
}
--
Erik Wikström
"djm" <dj*******@gmai l.comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.com.. .
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
When you put this in a header file
everyone using your header is now using
namespace std. Sort of defeats the
purpose. You should lose points for that <g> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew |
last post by:
I have written two classes : a String Class based on the book " C++ in
21 days " and a GenericIpClass listed below :
file GenericStringClass.h
// Generic String class
|
by: Tom Dacon |
last post by:
I'm curious to see if anyone has an opinion on this little design question -
I'm doing a computational astronomy library in C#, purely for my own use,
and one of the things that happens regularly is conversion of coordinates
from one frame of reference to another: spherical coordinates in the
ecliptic frame of reference, spherical coordinates in the equatorial frame
of reference, 3D rectangular coordinates in either, galactic coordinates,...
|
by: Krista Lemieux |
last post by:
Hello,
I know this is probably a hudge topic to discuss and
there are lots of different ways of implementation, but I
still would like to ask and hear the most commonly used
techniques for this.
Basically I have an ASP.NET application, and my
connection string currently is stored in a constant
public variable in one of my classes. The reason for that
is so that I only have one place to change the connection
string when I deploy it on a...
|
by: Stephen |
last post by:
Im new to VB.net....Im having a problem understandign how a constructor relates to the base form and a class.
What is the function on the constructor ..does it accept variables passed to it from the form?
Steve
|
by: aaa |
last post by:
Up until now I have used MS Web Services which are fairly straight-forward.
Now I am being asked to use some third party web services which I do not
find nearly as intuitive.
Questions:
1. I have a URL for a wsdl file only no URL to an aspx page such as with
MS. I have used this wsdl to make a proxy file. Do I still need to make a
"Web Reference" such as with an aspx file or does the proxy stub suffice?
2. I only see properties (not...
| |
by: CMM |
last post by:
Do the developers of Visual 2005 actuall use it??? There's lots of great
things in VS2005 (mostly related to the outstanding work done on the CLR)...
but in general the LITTLE THINGS totally drag it down.. especially the
slightly-improved-but-not-all-that-much IDE. I waited for 3 years for this?
Who's in charge of this mess?
1)
Editing a web form in the designer... I think I'm totally misunderstanding
the usage of CSS stylesheets and...
|
by: iTISTIC |
last post by:
Developing a new app and am trying to make this my first truly
OOP/3-Tier app. I understand the principles of the presentation,
business, and data layers. I do, however, have some questions on where
certain functionality should be placed and how some things should be
implemented.
Let's use a simple example such as an application to manage customer
records (customer_id, first_name, last_name). I'd have a Customer
business object with ID,...
|
by: Alan T |
last post by:
I am going to connect to the MySQL and Firebird database.
Is there any differenc in the connection string format from that of SQL
Server?
|
by: ommail |
last post by:
Hi
I wonder if regular expressions are in general sower than using
classes like String and
Char when used for validating/parsing text data?
I've done some simple test (using IsMatch()) method and the result was
that Regex
is either as fast or two times slower than method which used methods
from classes
|
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...
|
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,...
| |
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
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
| |
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...
| |