From: Anton Kerezov on
Hello everyone,

I'm new to wxWidgets so don't be angry if I ask stupid (for you)
questions. Here is my first question: how do I use wxList e.g
WX_DECLARE_LIST and WX_DEFINE_LIST

here is what I have:

=== Author.h ===
#ifndef AUTHOR_H
#define AUTHOR_H

WX_DECLARE_LIST(Book, BooksList);

class Author
{
public:
Author(wxString fName, wxString sName, wxString tName);
virtual ~Author();

...

BooksList * Books;

private:
wxString mFirstName;
wxString mSecondName;
wxString mThirdName;

...
};

=== Author.cpp ===
#include "wx/string.h"
#include "wx/list.h"
#include "Book.h"
#include "Author.h"

#include <wx/listimpl.cpp>
WX_DEFINE_LIST(BooksList);

Author::Author(wxString fName, wxString sName, wxString tName)
{
mFirstName = fName;
mSecondName = sName;
mThirdName = tName;
Books = new BooksList();
}

....


I'm doing the same with an AuthorCollection class that contains
WX_DECLARE_LIST(Author, AuthorsList); and WX_DEFINE_LIST(AuthorsList);

but i get many errors in particular:
Author.h|4|error: expected constructor, destructor, or type conversion
before '(' token|
Author.h|32|error: ISO C++ forbids declaration of 'BooksList' with no
type|

If anyone know what to do I will be very grateful. I'm running Ubuntu
7.10 with the latest C::B.

Thanks in advance,
Anton Kerezov

_______________________________________________
wx-users mailing list
wx-users(a)lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wx-users

From: Vadim Zeitlin on
On Sun, 23 Mar 2008 21:29:03 +0200 Anton Kerezov <ankere(a)gmail.com> wrote:

AK> I'm new to wxWidgets so don't be angry if I ask stupid (for you)
AK> questions. Here is my first question: how do I use wxList

First advise: don't do this. Just use std::list as usual. wxList exists
for historical reasons and there are (almost) no platforms where you still
need it nowadays. And if you really don't want to use the standard library
for whatever reason, consider at least using wxVector which is a template
class similar to std::vector implemented in wx/vector.h.

AK> WX_DECLARE_LIST and WX_DEFINE_LIST
AK>
AK> here is what I have:
AK>
AK> === Author.h ===
AK> #ifndef AUTHOR_H
AK> #define AUTHOR_H
AK>
AK> WX_DECLARE_LIST(Book, BooksList);
....
AK> I'm doing the same with an AuthorCollection class that contains
AK> WX_DECLARE_LIST(Author, AuthorsList); and WX_DEFINE_LIST(AuthorsList);
AK>
AK> but i get many errors in particular:
AK> Author.h|4|error: expected constructor, destructor, or type conversion
AK> before '(' token|

This probably means that Book is not defined at this point. You should
include Book.h or wherever it is declared before declaring a list of them.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.co
_______________________________________________
wx-users mailing list
wx-users(a)lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wx-users

From: Anton Kerezov on
Thanks Vadim

В нд, 2008-03-23 в 21:08 +0100, Vadim Zeitlin написа:
> On Sun, 23 Mar 2008 21:29:03 +0200 Anton Kerezov <ankere(a)gmail.com> wrote:
>
> AK> I'm new to wxWidgets so don't be angry if I ask stupid (for you)
> AK> questions. Here is my first question: how do I use wxList
>
> First advise: don't do this. Just use std::list as usual. wxList exists
> for historical reasons and there are (almost) no platforms where you still
> need it nowadays. And if you really don't want to use the standard library
> for whatever reason, consider at least using wxVector which is a template
> class similar to std::vector implemented in wx/vector.h.
>
> AK> WX_DECLARE_LIST and WX_DEFINE_LIST
> AK>
> AK> here is what I have:
> AK>
> AK> === Author.h ===
> AK> #ifndef AUTHOR_H
> AK> #define AUTHOR_H
> AK>
> AK> WX_DECLARE_LIST(Book, BooksList);
> ...
> AK> I'm doing the same with an AuthorCollection class that contains
> AK> WX_DECLARE_LIST(Author, AuthorsList); and WX_DEFINE_LIST(AuthorsList);
> AK>
> AK> but i get many errors in particular:
> AK> Author.h|4|error: expected constructor, destructor, or type conversion
> AK> before '(' token|
>
> This probably means that Book is not defined at this point. You should
> include Book.h or wherever it is declared before declaring a list of them.

I have included it in the Author.cpp file befor the inclusion of
Author.h but it is not working. I think I'm going to use std::list :)

_______________________________________________
wx-users mailing list
wx-users(a)lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wx-users