473,320 Members | 1,872 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,320 software developers and data experts.

How to Implement Aggregation concept in C++

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!!

Sep 6 '06 #1
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
Sep 6 '06 #2
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!!
Sep 6 '06 #3
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?
Sep 6 '06 #4
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.

Sep 6 '06 #5

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

Similar topics

4
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.
1
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#? ...
5
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...
4
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...
7
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...
23
by: SenthilVel | last post by:
Hi Can any one let me know the websites/Pdf for learning Aggragation in C#?? Thanks Senthil
1
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...
5
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...
2
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{ /* ... */ };...
4
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...
0
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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....
0
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

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.