By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,406 Members | 1,029 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,406 IT Pros & Developers. It's quick & easy.

COpy object

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a

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

P: n/a
"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

P: n/a

"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

P: n/a
> > >
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 discussion thread is closed

Replies have been disabled for this discussion.