I have an Account class in which Date object is a member of it.
When I created an account class:
These errors are coming up:
////////
:!g++ Account.cpp Account_main.cpp
/tmp/cclWe0e4.o(.text+0x17): In function
`Account::Account[not-in-charge]()':
: undefined reference to `Date::Date[in-charge](int, int, int)'
/tmp/cclWe0e4.o(.text+0x7d): In function
`Account::Account[in-charge]()':
: undefined reference to `Date::Date[in-charge](int, int, int)'
/tmp/ccGYfdzi.o(.text+0x20): In function `main':
: undefined reference to `Date::Date[in-charge](char*)'
/tmp/ccGYfdzi.o(.text+0x16f): In function `main':
: undefined reference to `Date::ToString(char*)'
collect2: ld returned 1 exit status
shell returned 1
////////
Account_main.cpp is place where I create an Account object.
Also please help in understanding these errors!!
********************************Account_main.cpp** *************************
#include <iostream>
#include "Account.h"
using namespace std;
int main(int argc, char **argv)
{
char acAccDate[11];
char acAccType[2];
//Account oA1;
//Date myDate("13-02-1988");
Account oA1(1322,23432,"SB",1000.00,Date("15-5-1999"));
//oA1.SetAccount(1322,23432,"SB",1000.00) : m_oDate("13-02-1988");
cout << "Account Details:" << endl;
cout << "No:" << oA1.GetAccNo() << endl;
oA1.GetAccType(acAccType);
cout << "Type:" << acAccType << endl;
cout << "Balance:" << oA1.GetBalance() << endl;
oA1.GetAccDate().ToString(acAccDate);
cout << "Date:" << acAccDate << endl;
return 0;
}
********************************Account.cpp******* ****************************
#include "Account.h"
#include <cstring>
Account::Account()
{
m_iCustId=0;
SetAccNo(0);
SetAccType("SB");
SetBalance(1000.00);
}
Account::Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance, Date oDate): m_oDate(oDate)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
/*m_oDate.m_iDay = oDate.m_iDay;
m_oDate.m_iMonth= oDate.m_iMonth;
m_oDate.m_iYear= oDate.m_iYear;*/
}
/*
Account::Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance) : m_oDate(Date sDate)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
}
*/
void Account::SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance, Date oDate)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
/*
m_oDate.m_iDay = oDate.m_iDay;
m_oDate.m_iMonth= oDate.m_iMonth;
m_oDate.m_iYear= oDate.m_iYear;
*/
}
void Account::SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
}
void Account::SetAccNo(unsigned long ulAccNo)
{
m_ulAccNo = ulAccNo;
}
/*Set the account type as given. By default set it as "SB"*/
void Account::SetAccType(char *acAccType)
{
( (strcasecmp(acAccType, "SB") == 0) && (strcasecmp(acAccType,
"CA")==0) && (strcasecmp(acAccType, "RD")==0) && (strcasecmp(acAccType,
"FD")==0) )
? strcpy(m_acAccType, acAccType) : strcpy(m_acAccType , "SB");
}
void Account::SetBalance(double dBalance)
{
m_dBalance = ( dBalance 1000.00) ? dBalance : 1000.00;
}
unsigned long Account::GetAccNo() const
{
return m_ulAccNo;
}
void Account::GetAccType( char *sType ) const
{
strcpy(sType, m_acAccType);
}
double Account::GetBalance() const
{
return m_dBalance;
}
Date Account::GetAccDate() const
{
return this->m_oDate;
}
*************************************Account.h**** **************************
#include "Date.h"
#ifndef _ACCOUNT_H
#define _ACCOUNT_H
class Account
{
private:
int m_iCustId;
unsigned long m_ulAccNo;
char m_acAccType[3];
double m_dBalance;
Date m_oDate;
public:
/*Constructor*/
Account();
Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance, Date oDate);
Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance);
/*Set Methods*/
void SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance, Date oDate);
void SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance);
void SetCustId(int iCustId);
void SetAccNo(unsigned long ulAccNo);
void SetAccType( char *acAccType );
void SetBalance(double dBalance);
/*Get Methods*/
//int GetCustId() const;
unsigned long GetAccNo() const;
void GetAccType( char *sType ) const;
double GetBalance() const;
Date GetAccDate() const;
};
#endif
************************************************** ****************************************
That was the code.
Please helpme!! 4 3521
Rajen wrote:
I have an Account class in which Date object is a member of it.
When I created an account class:
These errors are coming up:
////////
:!g++ Account.cpp Account_main.cpp
/tmp/cclWe0e4.o(.text+0x17): In function
`Account::Account[not-in-charge]()':
>undefined reference to `Date::Date[in-charge](int, int, int)'
[...]
"Undefined reference" usually means the compiler can see that you use
a function, but it can't see the function itself (the definition, the
body, the implementation). 'Date::Date' is a constructor. Did you
show your compiler where the implemenation of 'Date' class is located?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Rajen wrote:
I have an Account class in which Date object is a member of it.
When I created an account class:
These errors are coming up:
////////
:!g++ Account.cpp Account_main.cpp
Try it the other way round.
/tmp/cclWe0e4.o(.text+0x17): In function
`Account::Account[not-in-charge]()':
: undefined reference to `Date::Date[in-charge](int, int, int)'
/tmp/cclWe0e4.o(.text+0x7d): In function
`Account::Account[in-charge]()':
: undefined reference to `Date::Date[in-charge](int, int, int)'
/tmp/ccGYfdzi.o(.text+0x20): In function `main':
: undefined reference to `Date::Date[in-charge](char*)'
/tmp/ccGYfdzi.o(.text+0x16f): In function `main':
: undefined reference to `Date::ToString(char*)'
collect2: ld returned 1 exit status
shell returned 1
////////
Account_main.cpp is place where I create an Account object.
Also please help in understanding these errors!!
********************************Account_main.cpp** *************************
#include <iostream>
#include "Account.h"
using namespace std;
int main(int argc, char **argv)
{
char acAccDate[11];
char acAccType[2];
//Account oA1;
//Date myDate("13-02-1988");
Account oA1(1322,23432,"SB",1000.00,Date("15-5-1999"));
//oA1.SetAccount(1322,23432,"SB",1000.00) : m_oDate("13-02-1988");
cout << "Account Details:" << endl;
cout << "No:" << oA1.GetAccNo() << endl;
oA1.GetAccType(acAccType);
cout << "Type:" << acAccType << endl;
cout << "Balance:" << oA1.GetBalance() << endl;
oA1.GetAccDate().ToString(acAccDate);
cout << "Date:" << acAccDate << endl;
return 0;
}
********************************Account.cpp******* ****************************
#include "Account.h"
#include <cstring>
Account::Account()
{
m_iCustId=0;
SetAccNo(0);
SetAccType("SB");
SetBalance(1000.00);
}
Account::Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance, Date oDate): m_oDate(oDate)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
/*m_oDate.m_iDay = oDate.m_iDay;
m_oDate.m_iMonth= oDate.m_iMonth;
m_oDate.m_iYear= oDate.m_iYear;*/
}
/*
Account::Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance) : m_oDate(Date sDate)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
}
*/
void Account::SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance, Date oDate)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
/*
m_oDate.m_iDay = oDate.m_iDay;
m_oDate.m_iMonth= oDate.m_iMonth;
m_oDate.m_iYear= oDate.m_iYear;
*/
}
void Account::SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance)
{
m_iCustId = iCustId;
SetAccNo(ulAccNo);
SetAccType(acAccType);
SetBalance(dBalance);
}
void Account::SetAccNo(unsigned long ulAccNo)
{
m_ulAccNo = ulAccNo;
}
/*Set the account type as given. By default set it as "SB"*/
void Account::SetAccType(char *acAccType)
{
( (strcasecmp(acAccType, "SB") == 0) && (strcasecmp(acAccType,
"CA")==0) && (strcasecmp(acAccType, "RD")==0) && (strcasecmp(acAccType,
"FD")==0) )
? strcpy(m_acAccType, acAccType) : strcpy(m_acAccType , "SB");
}
void Account::SetBalance(double dBalance)
{
m_dBalance = ( dBalance 1000.00) ? dBalance : 1000.00;
}
unsigned long Account::GetAccNo() const
{
return m_ulAccNo;
}
void Account::GetAccType( char *sType ) const
{
strcpy(sType, m_acAccType);
}
double Account::GetBalance() const
{
return m_dBalance;
}
Date Account::GetAccDate() const
{
return this->m_oDate;
}
*************************************Account.h**** **************************
#include "Date.h"
#ifndef _ACCOUNT_H
#define _ACCOUNT_H
class Account
{
private:
int m_iCustId;
unsigned long m_ulAccNo;
char m_acAccType[3];
double m_dBalance;
Date m_oDate;
public:
/*Constructor*/
Account();
Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance, Date oDate);
Account(int iCustId, unsigned long ulAccNo, char *acAccType,
double dBalance);
/*Set Methods*/
void SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance, Date oDate);
void SetAccount(int iCustId, unsigned long ulAccNo, char
*acAccType, double dBalance);
void SetCustId(int iCustId);
void SetAccNo(unsigned long ulAccNo);
void SetAccType( char *acAccType );
void SetBalance(double dBalance);
/*Get Methods*/
//int GetCustId() const;
unsigned long GetAccNo() const;
void GetAccType( char *sType ) const;
double GetBalance() const;
Date GetAccDate() const;
};
#endif
************************************************** ****************************************
That was the code.
Please helpme!!
Rolf Magnus wrote:
Rajen wrote:
>I have an Account class in which Date object is a member of it. When I created an account class: These errors are coming up: //////// :!g++ Account.cpp Account_main.cpp
Try it the other way round.
>[..]
Did you *have* to quote the whole thing just to add one line?
Victor Bazarov wrote:
Rolf Magnus wrote:
>Rajen wrote:
>>I have an Account class in which Date object is a member of it. When I created an account class: These errors are coming up: //////// :!g++ Account.cpp Account_main.cpp
Try it the other way round.
>>[..]
Did you *have* to quote the whole thing just to add one line?
Definitely! No, just kidding. I was in a rush and forget to cut out the
source code. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Merlin |
last post by:
Hi
Imagine the following classes (A class diagram will help)
BASE, A, B, C, D, E, F, G.
A, B, C, D, G inherit from BASE.
E, F inherit from D.
|
by: Nice Chap |
last post by:
Aggregation in COM was defined as 'Exposing an interface of an inner object
by the outer object as though it were an interface of the outer object'. Is
this type of aggregation possible in c#?
...
|
by: John Wood |
last post by:
Let's say you're provided with an instance of a class. The instantiation
takes place in another module that you have no control over.
However, you've extended that class with your own value-added...
|
by: Frederik Vanderhaegen |
last post by:
Hi,
Can anyone explain me the difference between aggregation and composition?
I know that they both are "whole-part" relationships and that composition
parts are destroyed when the composition...
|
by: srinivas |
last post by:
Hi,
I am a asp programmer.I am displaying the db records in the
html pages in a web page.I have 500 columns and 1000 rows in that html
table.Here i am planning to implement the "MS-Excel Freeze...
|
by: SenthilVel |
last post by:
Hi
Can any one let me know the websites/Pdf for learning Aggragation in C#??
Thanks
Senthil
|
by: ninjutsu28 |
last post by:
hi im juz a student so pls bear with my terminologies..juz wana ask how
to perform aggregation in vb.net code..
in my model, i have rectangle, shape, drawing classes..rectangle class
inherits...
|
by: isetea |
last post by:
Hi,
I'm working on a access database to automate our Staff procedures a bit. One part is to select several informations from a table and to aggregate some of the outputs.
For example:
50 people...
|
by: Gary Wessle |
last post by:
Hi
what is the difference "in code writing" between aggregation and
composition?
is the following correct?
aggregation (life time of both objects are independent).
class A{ /* ... */ };...
|
by: Salman |
last post by:
The most confusing concept i have seen in OOP is the difference
between Association, Composition and Aggregation. Anyone please tell
me whats the actual difference between these three using...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |