Advertising (This ad goes away for registered users. You can Login or Register)

need expert in dev-c++ constructor

Programming on your favorite platform, for your favorite platform? Post here
Post Reply
alverich
Posts: 1
Joined: Fri Feb 11, 2011 6:29 pm

need expert in dev-c++ constructor

Post by alverich » Sat Mar 03, 2012 2:55 am

hello everyone, well i starting using constructors for initialize my private members in classes, well the problem comes when i create an objet in main(), let me show you an example:
class dog{
private:
members.....
public...
proto constructor.....
};
//real constructor
dog::dog(.....){
//initializing private variables};
......
int main(){
//creating objet
dog lazzy;

when i compile it give me an error, about theres no such function to call
in dog lazzy; but i only want to create an object, instead the compiler think i calling a function, i really dont know how to solve this,
please any help with this :(
sorry for my english
Advertising

User avatar
codestation
Big Beholder
Posts: 1660
Joined: Wed Jan 19, 2011 3:45 pm
Location: /dev/negi

Re: need expert in dev-c++ constructor

Post by codestation » Sat Mar 03, 2012 3:54 am

Why don't put some real code and the actual error message so you can get some real assistance?
instead the compiler think i calling a function
Well, you are calling a function: the constructor of that class. Your proto or real constructor is wrong and its hard to help without seeing the code for these. For example, this simple template compile without problems:

Code: Select all

#include <iostream>

class dog {
private:
    int foo;

public:
    dog();
};

dog::dog() {
    std::cout << "constructor called" << std::endl;
    foo = 0;
}

int main() {
    dog lazzy;
}
Advertising
Plugin list
Working on: QPSNProxy, QCMA - Open source content manager for the PS Vita
Playing: Error: ENOTIME
Repositories: github, google code
Just feel the code..

Post Reply

Return to “Programming”