473,399 Members | 3,888 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,399 software developers and data experts.

I am a C++ beginner

6
Hi,
Can you please help with this..
I need to develop a program that involves two classes: FileHandling and DataProcessing.
I have developed header files and implementation for both classes i.e. *.h and *.cpp
Now, in my main program I have created an object of each class and I want to use these objects to access the functions of these classes.

so my codes look something like this:

#includ "FileHandling.h"
#include "DataProcessing.h"

int main()
{
FileHandling file;
DataProcessing dp;

file.readfile();

return 0;
}

However, when I try to compile the main program, it gives me the following error about the called functions

" In function 'main': undefined reference to 'FileHandling::readfile()' collect2: ld returned 1 exit status"

I have all the files in one directory and I am working on Unix.
I use the following command to compile the program, where path is the location of the directory,:

g++ -Wall -Lpath -o Main Main.cpp

can you please help with? I have no clue what does this error mean

Thanks
Aug 29 '06 #1
3 1879
Banfa
9,065 Expert Mod 8TB
I think it might be useful to see the contents of FileHandling.h and FileHandling.cpp if they are not too long.
Aug 29 '06 #2
maabar
6
Ok, here are the files:

MyHeader.h:

#ifndef _HEADERF_H
#define _HEADERF_H


#include <iostream>
#include <string>

using namespace std;

class MyClass

{

public:

void SomeFunction();

int SomeNumber;

};

#endif

The "MyClass.cpp" file which provides the body for the classheader:

#include "classheader.h"
#include <iostream>
#include <string>

using namespace std;

class MyClass

{

public:

// One public member function

void SomeFunction();

// One public member variable

int SomeNumber;

};



// Definition of the function

void MyClass::SomeFunction()

{

// Output the number

cout << "SomeNumber is :"<<someNumber<<endl;

}

The main class "OClass.cpp":

// Including the header file we created

#include "classheader.h"

#include <iostream>
#include <string>

using namespace std;

void SomeFunction();

int main()

{

// Create a new instance of MyClass named mc

MyClass mc;

// Set the public variable of MyClass

mc.SomeNumber = 13;

// Call the public function of MyClass

mc.SomeFunction();

return 0;

}

When I compile the OClass.cpp file, I get the error that:
In function 'main': undefined reference to 'FileHandling::readfile()' collect2: ld returned 1 exit status"

Can you please help?

Thanks
Aug 30 '06 #3
Banfa
9,065 Expert Mod 8TB
Those are not the files as none of them contain the class FileHandling
Sep 1 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Richard B. Kreckel | last post by:
Hi! I was recently asked what book to recommend for a beginner in C++. I am convinced that you needn't study C in depth before learning C++ (though it helps), but cannot find any beginner's...
8
by: Grrrbau | last post by:
I'm a beginner. I'm looking for a good C++ book. Someone told me about Lafore's "Object-Oriented Programming in C++". What do you think? Grrrbau
7
by: Rensjuh | last post by:
Hello, does someone have / know a good C++ tutorial for beginnners? I would prefer Dutch, but English is also fine. Hoi, heeft / kent iemand nog een goede C++ tutorial voor beginners? Het liefste...
27
by: MHoffman | last post by:
I am just learning to program, and hoping someone can help me with the following: for a simple calculator, a string is entered into a text box ... how do I prevent the user from entering a text...
18
by: mitchellpal | last post by:
Hi guys, am learning c as a beginner language and am finding it rough especially with pointers and data files. What do you think, am i being too pessimistic or thats how it happens for a beginner?...
20
by: weight gain 2000 | last post by:
Hello all! I'm looking for a very good book for an absolute beginner on VB.net or VB 2005 with emphasis on databases. What would you reccommend? Thanks!
5
by: macca | last post by:
Hi, I'm looking for a good book on PHP design patterns for a OOP beginner - Reccommendations please? Thanks Paul
10
by: Roman Zeilinger | last post by:
Hi I have a beginner question concerning fscanf. First I had a text file which just contained some hex numbers: 0C100012 0C100012 ....
10
by: hamza612 | last post by:
I want to start learning how to program. But I dont know where to start. From what I've heard so far c++ is not a good lang. to learn as a beginner because its very complicated compared to others...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
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?
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
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,...
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
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.