473,395 Members | 1,556 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,395 software developers and data experts.

how to import classes in one class

6
Hi,
can anybody tell me the codes to import more than one class, i.e. (.cpp) file, into another class?

For example, if I have the following classes:
"class1.cpp"
"class2.cpp"

and I want to declare objects of these classes in my main class: "MainClass.cpp"

Do I need to declare header files for class1 and class2?

Also, what would be the compiling commands to compile "Mainclass.cpp"?

Thanks
Aug 30 '06 #1
2 2285
Banfa
9,065 Expert Mod 8TB
Yes include the header files for all the classes you wish to declare in your main class.

And it rather depends on which compiler you are using.
Aug 30 '06 #2
maabar
6
I am using g++ and I am using the following compiling commands:

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

where path is the location of the directory that has my files.

I am getting the following error messages:

"In 'main': undefined reference to 'Class1::somefunctions()':collect2:ld returened 1 exit status"

Any suggestions?
Aug 31 '06 #3

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

Similar topics

5
by: simo | last post by:
I've written a pretty big wxPython script, and I thought I'd split the source into a few files. I'm going to have a main.py file which includes global defs, wxApp initialisation code,...
1
by: Andrew James | last post by:
All, I'm having some trouble with understanding python's importing behaviour in my application. I'm using psyco to optimise part of my code, but I'm not sure whether it inherits throughout the...
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
0
by: Eric Huss | last post by:
I'm having a problem with packages within packages. Here's an example: foo/ foo/__init__.py: empty file foo/sub/__init__.py: from foo.sub.B import B foo/sub/A.py: class A: pass foo/sub/B.py
2
by: Shapper | last post by:
Hello, In the main root of my web site together with my aspx and aspx.vb files I have the file global.vb. This file has a class with all the functions which are used in many aspx.vb files and...
11
by: Brian Blazer | last post by:
OK, I have a very simple class here: class Student: """Defines the student class""" def __init__(self, lName, fName, mi): self.lName = lName self.fName = fName self.mi = mi
3
by: Seymour | last post by:
I created a module with the DictAdder subclass as follows: class DictAdder(Adder): def add(self, x, y): new={} for k in x.keys(): new=x for k in y.keys(): new=y return new At the...
49
by: Martin Unsal | last post by:
I'm using Python for what is becoming a sizeable project and I'm already running into problems organizing code and importing packages. I feel like the Python package system, in particular the...
4
by: spohle | last post by:
hi, i have written a small project for myself all in seperate classes and each of the classes lives in a seperate file. now i am looking for an import structure something like import wx, and...
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...
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
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...
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...

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.