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

COpy object

I have a class defined as follows:
public:
char Date[2 * BYTE];
char weight[6];
char Workout[2 * BYTE];
char Event[64];

TDaily* nxt_Daily;

I have defined my constructor/copy methods as shown:

TDaily* init_date(TDaily **pDaily);
TDaily* Copy(const TDaily &copy); // Copy constructor
void operator=(const TDaily &copy);

I try to use my copy constructor in my program as below:
TDaily bfr_date = tmp;

I get the following error:
Settings.cpp: In method `class TDaily * TDaily::Edit_date(TDaily **,
TBike *)':
Settings.cpp:698: conversion from `TDaily *' to non-scalar type `TDaily'
requested

I do not see where my fubar is... any ideas?

Joe

#----------------------------------------------------------#
# Penguinix Consulting #
#----------------------------------------------------------#
# Software development, QA and testing. #
# Linux support and training. #
# "Don't fear the penguin!" #
#----------------------------------------------------------#
# Registered Linux user: #309247 http://counter.li.org #
#----------------------------------------------------------#
Jul 22 '05 #1
8 3456
Joe Cipale wrote:
I have a class defined as follows:
public:
char Date[2 * BYTE];
char weight[6];
char Workout[2 * BYTE];
char Event[64];

TDaily* nxt_Daily;

I have defined my constructor/copy methods as shown:

TDaily* init_date(TDaily **pDaily);
TDaily* Copy(const TDaily &copy); // Copy constructor
void operator=(const TDaily &copy);

I try to use my copy constructor in my program as below:
TDaily bfr_date = tmp;

I get the following error:
Settings.cpp: In method `class TDaily * TDaily::Edit_date(TDaily **,
TBike *)':
Settings.cpp:698: conversion from `TDaily *' to non-scalar type `TDaily'
requested

I do not see where my fubar is... any ideas?


Post real code. And make it complete and compilable this time.

V
Jul 22 '05 #2
On Thu, 20 May 2004 15:20:02 -0700 in comp.lang.c++, Joe Cipale <jo**@aracnet.com> wrote,
TDaily* Copy(const TDaily &copy); // Copy constructor


That is no copy constructor.

Jul 22 '05 #3
Victor Bazarov wrote:

Joe Cipale wrote:
I have a class defined as follows:
public:
char Date[2 * BYTE];
char weight[6];
char Workout[2 * BYTE];
char Event[64];

TDaily* nxt_Daily;

I have defined my constructor/copy methods as shown:

TDaily* init_date(TDaily **pDaily);
TDaily* Copy(const TDaily &copy); // Copy constructor
void operator=(const TDaily &copy);

I try to use my copy constructor in my program as below:
TDaily bfr_date = tmp;

I get the following error:
Settings.cpp: In method `class TDaily * TDaily::Edit_date(TDaily **,
TBike *)':
Settings.cpp:698: conversion from `TDaily *' to non-scalar type `TDaily'
requested

I do not see where my fubar is... any ideas?


Post real code. And make it complete and compilable this time.

V


You want me to post over 10K lines of code?

Please...
--
#----------------------------------------------------------#
# "Don't fear the penguin!" #
#----------------------------------------------------------#
# Registered Linux user: #309247 http://counter.li.org #
#----------------------------------------------------------#
Jul 22 '05 #4
> I have defined my constructor/copy methods as shown:

TDaily* init_date(TDaily **pDaily);
TDaily* Copy(const TDaily &copy); // Copy constructor
void operator=(const TDaily &copy);


I think you need to define the copy constructor. The signature
for the constructor would be:

TDaily::TDaily( const TDaily &copy)

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - System Architecture Design CASE Tool
Jul 22 '05 #5

Joe,
this line doens't look right, constructors don't return values !
TDaily* Copy(const TDaily &copy); // Copy constructor
and
your assignment operator= doesn't look kosher as well,
void operator=(const TDaily &copy);
an assignment operator should return a reference:
TDaily& operator=( const TDaily& copy)

Also, the TDaily* stuff doens't seem good style, you should only
involve TDaily's and TDaily references, why would you want to
have a pointer, then you have to check it actually points to something!

dave

"Joe Cipale" <jo**@aracnet.com> wrote in message
news:40***************@aracnet.com...
I have a class defined as follows:
public:
char Date[2 * BYTE];
char weight[6];
char Workout[2 * BYTE];
char Event[64];

TDaily* nxt_Daily;

I have defined my constructor/copy methods as shown:

TDaily* init_date(TDaily **pDaily);
TDaily* Copy(const TDaily &copy); // Copy constructor
void operator=(const TDaily &copy);

I try to use my copy constructor in my program as below:
TDaily bfr_date = tmp;

I get the following error:
Settings.cpp: In method `class TDaily * TDaily::Edit_date(TDaily **,
TBike *)':
Settings.cpp:698: conversion from `TDaily *' to non-scalar type `TDaily'
requested

I do not see where my fubar is... any ideas?

Joe

#----------------------------------------------------------#
# Penguinix Consulting #
#----------------------------------------------------------#
# Software development, QA and testing. #
# Linux support and training. #
# "Don't fear the penguin!" #
#----------------------------------------------------------#
# Registered Linux user: #309247 http://counter.li.org #
#----------------------------------------------------------#

Jul 22 '05 #6
"Joe Cipale" <jo**@aracnet.com> wrote...
Victor Bazarov wrote:

Joe Cipale wrote:
I have a class defined as follows:
public:
char Date[2 * BYTE];
char weight[6];
char Workout[2 * BYTE];
char Event[64];

TDaily* nxt_Daily;

I have defined my constructor/copy methods as shown:

TDaily* init_date(TDaily **pDaily);
TDaily* Copy(const TDaily &copy); // Copy constructor
void operator=(const TDaily &copy);

I try to use my copy constructor in my program as below:
TDaily bfr_date = tmp;

I get the following error:
Settings.cpp: In method `class TDaily * TDaily::Edit_date(TDaily **,
TBike *)':
Settings.cpp:698: conversion from `TDaily *' to non-scalar type `TDaily' requested

I do not see where my fubar is... any ideas?


Post real code. And make it complete and compilable this time.

V


You want me to post over 10K lines of code?

Please...


No, I don't want you to post 10K lines of code. I want you to read
the damn FAQ 5.8 and follow its recommendations.
Jul 22 '05 #7

"Dave Townsend" <da********@comcast.net> wrote in message
news:Xq********************@comcast.com...

Joe,
this line doens't look right, constructors don't return values !
TDaily* Copy(const TDaily &copy); // Copy constructor


They aren't called Copy either!

john
Jul 22 '05 #8
> > >
I do not see where my fubar is... any ideas?


Post real code. And make it complete and compilable this time.

V


You want me to post over 10K lines of code?


You wrote 10K lines of code without realising you didn't have a copy
constructor!! Ever heard of incremental development? Unit testing?

john
Jul 22 '05 #9

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...
5
by: Tony Johansson | last post by:
Hello! I'm reading in a book about C++ and that is something that sound strange. It says "Pointers have reference-assignment semantics similar to those in Java. For example, after the...
16
by: bluekite2000 | last post by:
I want Matrix A(B) to create shallow copy of B but A=B to create deep copy of B. Is that bad design? Why and why not?
5
by: lion | last post by:
in .net, if you set annstance-A of a class equal to another instance-B, a pointer will add to B, but if i want to create a copy of B instead of pointer, how to operate? Note:serialization...
10
by: utab | last post by:
Dear all, So passing and returning a class object is the time when to include the definition of the copy constructor into the class definition. But if we don't call by value or return by value, ...
2
by: flamexx7 | last post by:
http://www.rafb.net/paste/results/V3TZeb28.html In this code, why copy constructor is not called while returning object from no_arg() . I was trying to find answer in C++ Standard. and there it's...
13
by: Jeroen | last post by:
Hi all, I'm trying to implement a certain class but I have problems regarding the copy ctor. I'll try to explain this as good as possible and show what I tried thusfar. Because it's not about a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...
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.