473,326 Members | 2,805 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,326 software developers and data experts.

a problem with pointers

4
Hello,

---------muziek.h-------------------------------------------------

#include <iostream>
#include<string>
#include<vector>
using namespace std;

class Muziekbestand
{
protected :
string artiest, naam;
int duur;
string bestandsnaam;
public :
Muziekbestand();
Muziekbestand(string naam);
void afspelen();
void printgegevens();
};

class Muzieklijsten
{
protected :
string naam;
vector<Muziekbestand> *lijst;

public:
Muzieklijsten();
Muzieklijsten(string lijstnaam);
void voegToe(Muziekbestand *a);
void verwijder(int a);
void search();



};

-----------------------------Muziekbestand.cpp----------------------------

#include <iostream>
#include<string>
#include<muziek.h>
using namespace std;

Muziekbestand::Muziekbestand()
{
artiest="";
naam= "";
duur=0;
bestandsnaam ="";

};
Muziekbestand::Muziekbestand(string a)
{
artiest="";
naam="";
duur=0;
bestandsnaam =a;
};
void Muziekbestand::afspelen()
{
cout << "u speelt nu " << naam << " van " << artiest << " met duur " << " en path " << bestandsnaam << endl;

};
void Muziekbestand::printgegevens()
{
cout <<"artiest: " << artiest << endl;
cout <<"naam: " << naam << endl;
cout <<"tijdsduur: " << duur << endl;
cout <<"path: " << bestandsnaam << endl;
};

--------------------------Muzieklijsten.cpp--------------------------------

#include <iostream>
#include<string>
#include<muziek.h>
#include <vector>
using namespace std;

Muzieklijsten::Muzieklijsten()
{
naam ="alle muziek" ;
}
Muzieklijsten::Muzieklijsten(string a)
{
naam=a;
}
void Muzieklijsten::voegToe(Muziekbestand *a)
{
lijst.push_back(a);
}
void Muzieklijsten::verwijder(int a)
{
lijst.erase(a);
}
void search()
{
cout << "geef een zoekwaarde in " << endl;
char ch;
cin >> ch;

};
------------------------------------------------------------------------
the problem here :
I have a class Muzieklijsten(Muziekbestand *a)
As far As I know it means : I will make a class Muzieklijsten and I will use a pointer to 'Muziekbestanden'

In mij class I want to add this pointer to a vector. but here I get the following error:

muzieklijsten.cpp:17: error: request for member `push_back' in `
this->Muzieklijsten::lijst', which is of non-aggregate type `
std::vector<Muziekbestand, std::allocator<Muziekbestand> >*'
muzieklijsten.cpp: In member function `void Muzieklijsten::verwijder(int)':


I have no clue what the problem is here.

I hope some one can solve this
thanks
Nov 27 '06 #1
1 1964
horace1
1,510 Expert 1GB
I think your vector
Expand|Select|Wrap|Line Numbers
  1.  vector<Muziekbestand> *lijst;
  2.  
should be
Expand|Select|Wrap|Line Numbers
  1. vector<Muziekbestand *> lijst;
  2.  
you then have a problem with
Expand|Select|Wrap|Line Numbers
  1. void Muzieklijsten::verwijder(int a)
  2. {
  3. lijst.erase(a);
  4. }
  5.  
erase() requires an interator as a parameter you are passing it an int
Nov 27 '06 #2

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

Similar topics

3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
27
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
6
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a...
19
by: s.subbarayan | last post by:
Dear all, I had this following doubt,while java is able to carryon with out pointers why C language cant be modified to remove pointer?Hows java able to do this with out pointers? I jus plead...
1
by: ketema | last post by:
Hello, I was wondering if someone could help me with a function I am trying to write. The purpose of the function is to read in text from a file in the following format: FIRSTNAME LASTNAME...
5
by: Paminu | last post by:
Why make an array of pointers to structs, when it is possible to just make an array of structs? I have this struct: struct test { int a; int b;
3
by: David Mathog | last post by:
This one is driving me slightly batty. The code in question is buried deep in somebody else's massive package but it boils down to this, two pointers are declared, the first is: char **resname...
1
by: ArcInversion | last post by:
Hi, I've been using a javascript script to create a dragon that flies across the page. Anyways, I'd like to make it so when you click the dragon it takes you to a new page. Was wondering if anyone...
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
2
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your...
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...
0
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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...

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.