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

List of arrays as a class member function

1
Hi!

This is approximately what I have: a class with a member var. that is a list of arrays. Member function addMsg should just appen a new message (which is an array of fixed length), but the compiler returns error, and since I am very new with all this stuff, I don't understand why. Can someone please help? The error I get is at the end.
Expand|Select|Wrap|Line Numbers
  1. typedef char  MsgBuffer_T[1024];
  2.  
  3. typedef  std::list<MsgBuffer_T> msgList_T;
  4.  
  5. class CMsgList{
  6. private:
  7.     msgList_T msgList;
  8.  
  9. public:
  10.  BOOL addMsg(MsgBuffer_T* pMsg);
  11. }
  12.  
  13. BOOL addMsg(MsgBuffer_T* pMsg){
  14.    msgList.push_back(*pMsg);
  15.  return TRUE; 
  16. }
  17.  
The error:
:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(34): error: a new-initializer may not be specified for an array
{new ((void _FARQ *)_P) _T1(_V); }
^
detected during:
instantiation of "void std::_Construct(_T1 *, const _T2 &) [with _T1=MsgBuffer_T, _T2=char [1024]]" at line 66
instantiation of "void std::allocator<_Ty>::construct(std::allocator<_Ty> ::pointer, const _Ty &) [with _Ty=MsgBuffer_T]" at line 222 of "C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\list"
instantiation of "std::list<_Ty, _A>::iterator std::list<_Ty, _A>::insert(std::list<_Ty, _A>::iterator, const _Ty &) [with _Ty=MsgBuffer_T, _A=std::allocator<MsgBuffer_T>]" at line 208 of "C:\Program Files\Microsoft Visual Studio\VC98\IN
CLUDE\list"
instantiation of "void std::list<_Ty, _A>::push_back(const _Ty &) [with _Ty=MsgBuffer_T, _A=std::allocator<MsgBuffer_T>]"
c
Sep 21 '07 #1
1 2050
Hello,

You should add a semicolon after the closing brace ending the class statement.
I also suggest that you typedef MsgBuffer_T to char * instead of char [1024].
Sep 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: M. Katz | last post by:
I'm trying to create a heirarchical linked list of sorts, and I'm looking for advice as to how best to set up the arrays. In other languages, I might use a pointer array to other pointer arrays,...
8
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
34
by: Dennis | last post by:
I would like to dynamically allocate in a sub a 2 dimensional Array float *myarray = new float ; of course I get an error. How do you allocate a 2D array using the New operator? I...
5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
21
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
11
by: Justin Naidl | last post by:
class Foo { protected: char foo_stuff; public: char* get_foo_stuff(); } Given the above example. What I want to know is the "proper/standard" way
3
by: jason | last post by:
Hello. I've got this simple collection populate code I downloaded from the net (sorry can't find source now) I'm trying to test, but I can't seem to get it to work. Any help would be greatly...
5
by: nelly0 | last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.