473,326 Members | 2,588 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.

What's going on here: error: no matching function for call

Hi I'm experiencing a strange problem.
which after scratching my head for while an not being able to see anything wrong i managed to fix in an unsatisfactory way, but hopefully this gives some insight into what is happening.

I'm using g++ and pushing onto an stl vector

however the line :

Expand|Select|Wrap|Line Numbers
  1. oc->features->push_back(new TopologyFeature(wTop,oc));
  2.  
causes the error:
error: no matching function for call to ‘TopologyFeature::TopologyFeature()’

so it seems to want a default constructor. I'm not sure why as i don't want to have a default constructor if i can avoid it.

however create a pointer to the same object type (and dont do anything with it) like so:
Expand|Select|Wrap|Line Numbers
  1. TopologyFeature* t;
  2. oc->features->push_back(new TopologyFeature(wTop,oc));
  3.  
there is no error thrown.
if its not a pointer but an object i get the same error.

Expand|Select|Wrap|Line Numbers
  1. TopologyFeature t;
  2. oc->features->push_back(new TopologyFeature(wTop,oc));//same error
  3.  
when i push another similar object of same base type on the vector i do not get any such error and this one does not have a default constructor either.

Expand|Select|Wrap|Line Numbers
  1. oc->features->push_back(new TemporalChangeFeature2(wtChange, oc));//works fine
  2.  
this all seems a little strange and i wonder if anyone can explain what is going on.
May 30 '11 #1
2 2718
Strangely (though i'm not aware of changing anything) this problem seems to have gone away. I going to put it down as one of those strange mysteries that sometimes seems to occur and ignore it.
May 30 '11 #2
weaknessforcats
9,208 Expert Mod 8TB
This code compiles and links OK using Visual Studio 2008:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3. #include <vector>
  4.  
  5. class X
  6. {
  7. public:
  8.     X(int);
  9.  
  10. };
  11. X::X(int arg)
  12. {
  13.  
  14. }
  15.  
  16. int main()
  17. {
  18.   vector<X*> data;
  19.   data.push_back(new X(3));
  20. }
Is your features a vector of TopologyFeature*?

and has the compiler seen the class definition?
May 31 '11 #3

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

Similar topics

1
by: A. Farber | last post by:
Hi, I'm trying to port a bigger program from Visual C++ to Linux and after rewriting few Visual C++ functions (strnicmp, filelength, findnext, etc.) I'm finally down to just one (!) error...
0
by: H. S. | last post by:
Hi, I am trying to compile the examples in arpack++ library on x86 Linux (flavor of Red Hat) running 2.4.24 kernel and g++ (3.2 20020903 version). Here is part of the compiler error I am...
2
by: Lateralus | last post by:
headers/vector3.h: In member function ‘Vector3 Vector3::operator*(Scalar)’: headers/vector3.h:13: error: no matching function for call to ‘Vector3::Vector3(Vector3)’...
2
by: gakman_2006 | last post by:
I am trying to get an onclick event to pass some values to a function to display in an alert box for now. I can get it sort of working but now the way I need it. I will be changing the alert in the...
5
by: Martin Jørgensen | last post by:
Hello again, Sorry to bother but I guess my C++ book isn't very good since it obviously contains errors so the program code doesn't work with g++. However I don't understand what the problem...
16
by: Martin Jørgensen | last post by:
Hi, Short question: Any particular reason for why I'm getting a warning here: (cast from function call of type int to non-matching type double) xdouble = (double)rand()/(double)RAND_MAX;
1
by: yuanhp_china | last post by:
I define a class: class RtServer { public: RtServer(); void init(); void close();
4
by: ask84 | last post by:
Hi. I'm Alize. I'm taking Intro to Programming C++. I enjoy this class but sometimes I'm really bad with the programming I just cannot believe why do I do silly mistake. Here are the instructions...
2
by: hectic | last post by:
i have three file header file where i define the function prototype and the other implementaion file for the function body and other one is the test file which takes input for the implementation file...
2
by: cablepuff | last post by:
template <typename ContainerType> ContainerType rsa_encrypt_list(const std::string&, const typename ContainerType::reference, const typename ContainerType::reference); const BigInteger...
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...
1
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.