Welcome! Log In Create A New Profile

Advanced

Please help! problem with getStatement

Posted by Iqbal 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Please help! problem with getStatement
July 27, 2006 01:22PM
Hi,

I have just too much on my plate at the moment and is losing it. I go the hard part to work but am battling for many days to get the statement part working. Please assist, I need to hand by tomorrow as I leave on business.

Here is what I have done so far!


Declaerd under account_impl.h
Account::Transaction transac;

Q? how do I declare a list storage container to insert transac elements?

void Account_impl::deposit( CORBA::ULong amount )
throw(
::CORBA:confused smileyystemException)

{
bal += amount;
transac.direction = Account::Transaction::deposit;
transac.amount = amount;


}
For the get Statement, I want create a new statement and copy my list elements into this and declare it. I have done the following.

::Account:confused smileytatement* Account_impl::getStatement()
throw(::CORBA:confused smileyystemException)

{
Statement * k = new Statement[list.lenght()]; //

unsigned int i;
for (i=1, i <= list.lenght(), i++)
{
k = translist;
cout << k->amount << endl;
}

Re: Please help! problem with getStatement
July 27, 2006 01:46PM
std::list<Account::Transaction>

Re: Please help! problem with getStatement
July 27, 2006 03:18PM
Hi Bob,
I wish it was that simple, I tried this many times.This is the following error.

I declared this in my header file.
std::list<Account::Transaction> translist;

This is my implementation
void Account_impl::deposit( CORBA::ULong amount )
throw(
::CORBA:confused smileyystemException)

{
bal += amount;
transac.direction = Account::Transaction::deposit;
transac.amount = amount;
translist.insert(transac);
}

Error I get when running gmake

C:\unisa\mico\demo\ass3>gmake
c:/unisa/mico/bin/idl.exe account.idl
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o account.o account.cc
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o client.o client.cc
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -mthreads -Lc:/unisa/mico/lib
s account.o client.o c:/unisa/mico/bin/mico2311.dll -lmicocoss2.3.11 -lpthread -
o client
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o server.o server.cc
In file included from server.cc:8:
account_impl.cc: In member function `virtual void Account_impl::deposit(long
unsigned int)':
account_impl.cc:24: no matching function for call to `
std::list<Account::Transaction, std::allocator<Account::Transaction> >::
insert(Account::Transaction&winking smiley'
C:/unisa/mingw/include/c++/3.2.3/bits/stl_list.h:429: candidates are:
std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, const _Tp&winking smiley [with _Tp
= Account::Transaction, _Alloc = std::allocator<Account::Transaction>]
C:/unisa/mingw/include/c++/3.2.3/bits/stl_list.h:440:
std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>winking smiley [with _Tp =
Account::Transaction, _Alloc = std::allocator<Account::Transaction>]
C:/unisa/mingw/include/c++/3.2.3/bits/stl_list.h:464: void
std::list<_Tp, _Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>,
unsigned int, const _Tp&winking smiley [with _Tp = Account::Transaction, _Alloc =
std::allocator<Account::Transaction>]
gmake: *** [server.o] Error 1
Re: Please help! problem with getStatement
July 27, 2006 03:36PM
The list should be a data member of your Account_impl class, not forlornly declared somewhere in your .h file.
Re: Please help! problem with getStatement
July 27, 2006 04:36PM
I think I definetly need a break bob, I am blanking out. It's my falut I have not said what I tried upfront. I tried this as well. here is my accoutn_impt class.

#include "account_impl.h"
#include <string>
#include <map>
#include <list>

// Implementation for interface Account

std::list<Account::Transaction> translist;


Account_impl::Account_impl ()
{
bal = 0;

}

void Account_impl::deposit( CORBA::ULong amount )
throw(
::CORBA:confused smileyystemException)

{
bal += amount;
transac.direction = Account::Transaction::deposit;
transac.amount = amount;
translist.insert(transac);
}

I think it might be my translist.insert.


Give me the following error when runnig gmake.

C:\unisa\mico\demo\ass3>gmake
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -mthreads -Lc:/unisa/mico/lib
s account.o client.o c:/unisa/mico/bin/mico2311.dll -lmicocoss2.3.11 -lpthread -
o client
g++ -mthreads -Ic:/unisa/mico/include -D_REENTRANT -c -o server.o server.cc
In file included from server.cc:8:
account_impl.cc: In member function `virtual void Account_impl::deposit(long
unsigned int)':
account_impl.cc:25: no matching function for call to `
std::list<Account::Transaction, std::allocator<Account::Transaction> >::
insert(Account::Transaction&winking smiley'
C:/unisa/mingw/include/c++/3.2.3/bits/stl_list.h:429: candidates are:
std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, const _Tp&winking smiley [with _Tp
= Account::Transaction, _Alloc = std::allocator<Account::Transaction>]
C:/unisa/mingw/include/c++/3.2.3/bits/stl_list.h:440:
std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>winking smiley [with _Tp =
Account::Transaction, _Alloc = std::allocator<Account::Transaction>]
C:/unisa/mingw/include/c++/3.2.3/bits/stl_list.h:464: void
std::list<_Tp, _Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>,
unsigned int, const _Tp&winking smiley [with _Tp = Account::Transaction, _Alloc =
std::allocator<Account::Transaction>]
gmake: *** [server.o] Error 1
Re: Please help! problem with getStatement
July 27, 2006 05:31PM
Sorry for being dummy, I found my problem, list.insert change to list.push_back.
Re: Please help! problem with getStatement
July 28, 2006 11:25AM
Iqbal glad to see you have solved 1 problem.

You do need to make the list a member of individual accounts though. You can't have a global transaction list for all accounts.

Bob
Sorry, only registered users may post in this forum.

Click here to login