COpy object

J

Joe Cipale

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 #
#----------------------------------------------------------#
 
V

Victor Bazarov

Joe said:
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
 
J

Joe Cipale

Victor said:
Joe said:
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 #
#----------------------------------------------------------#
 
E

EventHelix.com

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
 
D

Dave Townsend

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
 
V

Victor Bazarov

Joe Cipale said:
Victor said:
Joe said:
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.
 
J

John Harrison

Dave Townsend said:
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
 
J

John Harrison

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top