C++, Problem with List (insert)

Hi all,
I'm trying to make a simple program: I need to create a class Blog, where Posts can be added. When a Post is added (Blog::newPost(Post p)) all Subscribers are Notifyed. I "eredited" 2 classes from Subscriber, which are notifyed in a different way.

Here is some code.

the postList and subscribersList:
[code] std::list elencoPost;
std::list elencoIscritti;[/code]

to add new posts I use:
[code]void Blog::newPost(Post ultimo) {

Notify(); // notify subscribers

main adds posts this way:

and this works fine. so i made the same with the Subscriber (if you're asking why I use 2 methods, it was required by project specifications):
[code]void Subscriber::attach(Blog b) {


void Blog::iscrizione(Subscriber subs) {


the problem is that elencoIscritti (the List of Subscribers) does not "keep" the Subscriber I insert. for example:
- when in attach(Blog b) elencoIscritti.size() = 0;
- when in iscrizione(Subscriber s) elencoIscritti.size() = 1;
- when in main() elencoIscritti.size() = 0;

the List works fine with Post, but with Subscriber I have this problem.. :(

Any Idea?

thank you very much in advance

EDIT: solved. I needed:
instead of:

bye bye
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!