473,404 Members | 2,195 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,404 software developers and data experts.

could you help me to debug?

the following code is copy from a file called "abc.cpp"
i can compile it suscessfully, but an error occur when i run it
the error message is
--------------------Configuration: abc - Debug--------------------
Linking...
C:\abc.o(.text+0x59): In function `main':
C:\abc.cpp:14: undefined reference to `abc::abc()'

abc.exe - 1 error(s), 0 warning(s)

why?
thanks!

#include<iostream>
using namespace std;
class abc{
public:
abc();
void test();
};

void abc::test(){
cout<<"Testing"<<endl;
}

int main(int argc, char *argv[]){
abc a;
a.test();

return 0;
}
Nov 20 '05 #1
3 1213
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

nick wrote:
the following code is copy from a file called "abc.cpp"
The name of your program is the first clue to the error
i can compile it suscessfully, but an error occur when i run it
the error message is
--------------------Configuration: abc - Debug--------------------
Linking...
C:\abc.o(.text+0x59): In function `main':
C:\abc.cpp:14: undefined reference to `abc::abc()'

abc.exe - 1 error(s), 0 warning(s)

why?
thanks!

#include<iostream>

And here's another

You have at least one big problem. You are asking a C++ compilation question
in a group that does not discuss C++. comp.lang.c is dedicated to discussion
of program development in standards-compliant C language, and has nothing to
do with C++

You might try asking your question in comp.lang.c++, which is just down the
hall - second door on the right, just past the water cooler.

Otherwise, you need to ask in a group dedicated to your specific
compiler/operating environment - you'll likely find them in upstairs - four
flights up.

- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)

iD8DBQFDgKK2agVFX4UWr64RAsoUAKDTmQFr3Fm5jSdNiZSiKC OtPVWP/QCfcTAT
ICLSltaBmBhMo3Ra11fat8w=
=C8JN
-----END PGP SIGNATURE-----
Nov 20 '05 #2
nick wrote:
the following code is copy from a file called "abc.cpp"
i can compile it suscessfully, but an error occur when i run it
the error message is
--------------------Configuration: abc - Debug--------------------
Linking...
C:\abc.o(.text+0x59): In function `main':
C:\abc.cpp:14: undefined reference to `abc::abc()'

abc.exe - 1 error(s), 0 warning(s)

why?
thanks!

#include<iostream>
using namespace std;
class abc{
public:
abc();
void test();
};

void abc::test(){
cout<<"Testing"<<endl;
}

int main(int argc, char *argv[]){
abc a;
a.test();

return 0;
}


comp.lang.c is a forum for the discussion of the C language. You have
posted a
C++ program. You should ask C++ questions on comp.lang.c++.

<off topic>
as your compiler suggested you have no definition for the function
abc()
<end>
--
Nick Keighley

Nov 20 '05 #3

"Nick Keighley" <ni******************@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
| nick wrote:
|
| > the following code is copy from a file called "abc.cpp"
| > i can compile it suscessfully, but an error occur when i run it
| > the error message is
| > --------------------Configuration: abc - Debug--------------------
| > Linking...
| > C:\abc.o(.text+0x59): In function `main':
| > C:\abc.cpp:14: undefined reference to `abc::abc()'
| >
| > abc.exe - 1 error(s), 0 warning(s)
| >
| > why?
| > thanks!
| >
| > #include<iostream>
| > using namespace std;
| > class abc{
| > public:
| > abc();
| > void test();
| > };

Where is the abc ctor defined? Thats exactly what the compiler is asking
you. Since you've decared a ctor, you've told the compiler not to
generate a default ctor, therefore, its looking for your abc::abc()
definition.

By the way, its convention that a struct or class by capitalized in
order to help you identify the type and the instances of the type.

class A
{
public:
A() { }
~A() { }
};

int main()
{
A a;
}

| >
| > void abc::test(){
| > cout<<"Testing"<<endl;
| > }

That function should have been declared in the class declaration as

void test() const;

....since its not modifying the instance of that class in any way.
(void test() does not require the presence of the "this" pointer)

| >
| > int main(int argc, char *argv[]){
| > abc a;
| > a.test();
| >
| > return 0;
| > }
|
| comp.lang.c is a forum for the discussion of the C language. You have
| posted a
| C++ program. You should ask C++ questions on comp.lang.c++.
|
| <off topic>
| as your compiler suggested you have no definition for the function
| abc()
| <end>
|
|
| --
| Nick Keighley
|
Nov 20 '05 #4

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

Similar topics

2
by: Bill Davy | last post by:
sys.path: H:\Husky\HostPC\V1\SHIP\Debug H:\Husky\HostPC\V1\SHIP E:\Bill\Python-2.4.1\PCbuild\python24_d.zip C:\Python24\Lib C:\Python24\DLLs C:\Python24\Lib\lib-tk H:\Husky\HostPC\V1\RunSHIP...
1
by: Afaq | last post by:
Hi, After adding large number of empty resource files (which will be updated later), we are not able to compile the project. the following is the output of the build process. It fails while...
3
by: Mahmood Ahmad | last post by:
Hello, I have written a program that reads three types of records, validates them acording to certain requirements and writes the valid records into a binary file. The invalid records are...
1
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h...
0
by: mdavidjohnson | last post by:
In VS.NET 2003 (VB.NET): Microsoft Development Environment 2003 Version 7.1.3088 Microsoft .NET Framework 1.1 Version 1.1.4322 SP1 Here's a small piece of code which works fine: Private Sub...
4
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG:...
4
by: Marek Krzeminski | last post by:
I am new to ASP and I am having some problems that I hope someone can help me with. I am using WindowsXP and a book to try to learn ASP. The book instructed me to install IIS & .Net Framework...
2
by: MLH | last post by:
I would like to populate a table with the following information: tblPropertySettings - the GotFocus property setting string - the LostFocus property setting string I'd like to document...
2
by: theronnightstar | last post by:
I am writing an anagram program for my fiance. Figured it would be an excellent task to learn from. The way it is supposed to work is it reads in a word list from a file into a temporary...
1
by: Doctorslicer | last post by:
Hi All, We have a large multi project application in MFC that we are converting to managed code. We have been able to add /CLR to all of the projects and have compiled successfully but encounter...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
isladogs
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...

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.