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

Help with copy constructor

I am confused and need alittle help with a program i am writting and
cannot for the life of me remember how to get the copy constuctor using
stack class to work... i know exactly what i have to do but cannot
remember how to get the copy constructor organanization goes. i
remember its something like:

for (int blah blah)

new (int) A=a.[x]

something like that? can anyone help?... i also need to copy 2 arrays

Sep 7 '05 #1
4 2003
coke wrote:
I am confused and need alittle help with a program i am writting and
cannot for the life of me remember how to get the copy constuctor
using stack class to work...
Huh?
i know exactly what i have to do but
cannot remember how to get the copy constructor organanization goes.
i remember its something like:

for (int blah blah)

new (int) A=a.[x]

something like that? can anyone help?... i also need to copy 2 arrays


Please post more code (and real code this time). Expression

'new (int) A=a.[x]'

is definitely not C++, but there is no way to suggest anything without
knowing what you're trying to accomplish.

V
Sep 7 '05 #2
well what i am trying to do is a copy an array and destroy the extra
integers that i no longer need after they are used. So i am trying to
make a copy constructor and a destructor so i can copy an array for
only what i need. it is a calculator program and when i find a ) i
need to stop the program and calculate it and continue for example

((6+4)-1)
so it can do 6+4 and destroy (6+4) to then make it (10-1)
The ( and ) are integers and the addition and multipication are
different arrays
hope this helps thanks.

Sep 7 '05 #3
coke wrote:
well what i am trying to do is a copy an array and destroy the extra
integers that i no longer need after they are used. So i am trying to
make a copy constructor and a destructor so i can copy an array for
only what i need. it is a calculator program and when i find a ) i
need to stop the program and calculate it and continue for example

((6+4)-1)
so it can do 6+4 and destroy (6+4) to then make it (10-1)
The ( and ) are integers and the addition and multipication are
different arrays
hope this helps thanks.


My advice would be not to use array for such a fragile task. Use the
containers in the stl (standard template library). If you are not
familar with them, you will definetly need to read a good book about
them - you'll need them all the time.

As for your question: I still do not understand well enough what you
want to do to help you with the task. Sorry.

Gabriel
Sep 7 '05 #4

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

Similar topics

42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
2
by: dinks | last post by:
Hi, I'm new to C++ and have been assigned a task which i dont completely understand. Any help would be greately appreciated. Here is the problem: The class "linkedListType" use the "assert"...
7
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help...
4
by: Jim Langston | last post by:
I understand the rule of three, that if I have a custom constructor, copy or destructor I probably need the other 2. My class object definately has a custom constructor and destructor, but I'm...
8
by: shuisheng | last post by:
Dear All, I am wondering how the default copy constructor of a derived class looks like. Does it look like class B : public A { B(const B& right) : A(right) {}
5
by: satan | last post by:
I need a help in my method equalStack in my class StackClass. public class StackClass { private int maxStackSize; //variable to store the maximum ...
8
by: john | last post by:
Hey guys, Quick question i have this code and what i want to do is create a deep copy of class B. Now I tried doing this with the new operator and pointers. Here's is the orignal ...
0
by: bayan1 | last post by:
The following program have the following output. write the necessary code to make it works? Code : #include <iostream> using namespace std; class Point { private: int x; int y; public:
3
by: Stephen Torri | last post by:
Below is a class that is suppose to represent a segment of memory or a contents of a binary image (e.g. ELF executable). I have started to read Modern C++ Design and thought the best way to ensure...
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:
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
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...
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.