Hi All,
I am trying to create a class whose constructor takes Void
parameter and stores it for future reference. It works fine as
expected.
class base
{
public:
base(LPVOID pObj){ //store lpvoid for reference};
virtual ~base(){};
virtual void func1() { printf("Hello from base\n") };
};
When I create another class from above given class and try to create
object from it, it get following error.
error C2664: 'derived::derived' : cannot convert parameter 1 from
'const int' to 'const class derived &'
Reason: cannot convert from 'const int' to 'const class
derived'
No constructor could take the source type, or constructor
overload resolution was ambiguous
class derived:public base
{
protected:
virtual void func1(){ printf("Hello from Derived\n") };
};
int main()
{
base *nderived= new derived(NULL); //error
}
Please can any one help me to make this working.
Thanks and Regards 5 1792
On Tue, 21 Aug 2007 04:14:31 -0700, Ami wrote:
Hi All,
I am trying to create a class whose constructor takes Void
parameter and stores it for future reference. It works fine as
expected.
class base
{
public:
base(LPVOID pObj){ //store lpvoid for reference};
virtual ~base(){};
virtual void func1() { printf("Hello from base\n") };
};
When I create another class from above given class and try to create
object from it, it get following error.
error C2664: 'derived::derived' : cannot convert parameter 1 from
'const int' to 'const class derived &'
Reason: cannot convert from 'const int' to 'const class
derived'
No constructor could take the source type, or constructor
overload resolution was ambiguous
class derived:public base
{
protected:
virtual void func1(){ printf("Hello from Derived\n") };
public:
derived(LPVOID v) : base(v) {}
};
int main()
{
base *nderived= new derived(NULL); //error
}
Please can any one help me to make this working.
Thanks and Regards
--
Obnoxious User
On Aug 21, 4:14 pm, Ami <ver_amit...@yahoo.comwrote:
Hi All,
I am trying to create a class whose constructor takes Void
parameter and stores it for future reference. It works fine as
expected.
class base
{
public:
base(LPVOID pObj){ //store lpvoid for reference};
virtual ~base(){};
virtual void func1() { printf("Hello from base\n") };
};
When I create another class from above given class and try to create
object from it, it get following error.
error C2664: 'derived::derived' : cannot convert parameter 1 from
'const int' to 'const class derived &'
Reason: cannot convert from 'const int' to 'const class
derived'
No constructor could take the source type, or constructor
overload resolution was ambiguous
class derived:public base
{
protected:
virtual void func1(){ printf("Hello from Derived\n") };
};
int main()
{
base *nderived= new derived(NULL); //error
}
Please can any one help me to make this working.
Thanks and Regards
Since the base class constrcutor needs a argument, you derived class'
constructor should provide it.
class derived : public base
{
derived(void*):base(NULL){}
}
would make your code compile..
Best Regards,
Senthil
On 8/21/2007 1:14 PM, Ami wrote:
Hi All,
I am trying to create a class whose constructor takes Void
parameter and stores it for future reference. It works fine as
expected.
class base
{
public:
base(LPVOID pObj){ //store lpvoid for reference};
virtual ~base(){};
virtual void func1() { printf("Hello from base\n") };
};
When I create another class from above given class and try to create
object from it, it get following error.
error C2664: 'derived::derived' : cannot convert parameter 1 from
'const int' to 'const class derived &'
Reason: cannot convert from 'const int' to 'const class
derived'
No constructor could take the source type, or constructor
overload resolution was ambiguous
class derived:public base
{
protected:
virtual void func1(){ printf("Hello from Derived\n") };
};
int main()
{
base *nderived= new derived(NULL); //error
}
Please can any one help me to make this working.
Thanks and Regards
derived does not have a c'tor that's able to take 'NULL'.
You have to declare that c'tor in class derived.
Regards,
Stefan
--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
On Aug 21, 4:16 pm, Obnoxious User <O...@127.0.0.1wrote:
On Tue, 21 Aug 2007 04:14:31 -0700, Ami wrote:
Hi All,
I am trying to create a class whose constructor takes Void
parameter and stores it for future reference. It works fine as
expected.
class base
{
public:
base(LPVOID pObj){ //store lpvoid for reference};
virtual ~base(){};
virtual void func1() { printf("Hello from base\n") };
};
When I create another class from above given class and try to create
object from it, it get following error.
error C2664: 'derived::derived' : cannot convert parameter 1 from
'const int' to 'const class derived &'
Reason: cannot convert from 'const int' to 'const class
derived'
No constructor could take the source type, or constructor
overload resolution was ambiguous
class derived:public base
{
protected:
virtual void func1(){ printf("Hello from Derived\n") };
public:
derived(LPVOID v) : base(v) {}
};
int main()
{
base *nderived= new derived(NULL); //error
}
Please can any one help me to make this working.
Thanks and Regards
--
Obnoxious User
Hi Obnoxious,
Many thanks for reply. It works as expected. Thanks again.
Regards
On Aug 21, 4:57 pm, Ami <ver_amit...@yahoo.comwrote:
On Aug 21, 4:16 pm, Obnoxious User <O...@127.0.0.1wrote:
On Tue, 21 Aug 2007 04:14:31 -0700, Ami wrote:
Hi All,
I am trying to create a class whose constructor takes Void
parameter and stores it for future reference. It works fine as
expected.
class base
{
public:
base(LPVOID pObj){ //store lpvoid for reference};
virtual ~base(){};
virtual void func1() { printf("Hello from base\n") };
};
When I create another class from above given class and try to create
object from it, it get following error.
error C2664: 'derived::derived' : cannot convert parameter 1 from
'const int' to 'const class derived &'
Reason: cannot convert from 'const int' to 'const class
derived'
No constructor could take the source type, or constructor
overload resolution was ambiguous
class derived:public base
{
protected:
virtual void func1(){ printf("Hello from Derived\n") };
public:
derived(LPVOID v) : base(v) {}
};
int main()
{
base *nderived= new derived(NULL); //error
}
Please can any one help me to make this working.
Thanks and Regards
--
Obnoxious User
Hi Obnoxious,
Many thanks for reply. It works as expected. Thanks again.
Regards
Many thanks all of you for suggestion.
Regards, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ryan Mitchley |
last post by:
Hi all
I have code for an object factory, heavily based on an article by Jim Hyslop
(although I've made minor modifications). The factory was working fine using
g++, but since switching to the...
|
by: John Ratliff |
last post by:
When I dereference a pointer, does it make a copy of the object?
Say I had a singleton, and wanted an static method to retrieve it from
the class.
class foo {
private:
static foo *bar;
...
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you...
|
by: Andrew Poulos |
last post by:
With the following code I can't understand why this.num keeps
incrementing each time I create a new instance of Foo. For each instance
I'm expecting this.num to alert as 1 but keeps incrementing.
...
|
by: Arpan |
last post by:
Consider the following code that adds a table to a DataSet dynamically:
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
'Create an empty DataSet
Dim dSet As...
|
by: manstey |
last post by:
Hi,
I am having trouble designing my classes.
I have two classes. The first one wraps around an old-style class
called oref
Class CacheClass(object):
def __init__(self, obj):
|
by: JH |
last post by:
Hi
I found that a type/class are both a subclass and a instance of base
type "object".
It conflicts to my understanding that:
1.) a type/class object is created from class statement
2.) a...
|
by: JohnQ |
last post by:
Why would anyone write:
class SomeThing // class littered with non-domain single-instancing code :(
{
private:
SomeThing();
static SomeThing* pInstance_;
public:
static SomeThing*...
|
by: mitrofun63 |
last post by:
Hi, All
I have trouble with db2 instance creation (DB2 9.1.2 on AIX 5.3)
When i run command for instance creation :
../db2icrt -a SERVER -p 50000 -s ese -u db2fenc1 db2inst1
a reciveve...
|
by: Andy B |
last post by:
I have an instance of an object that needs to be accessed by all members of
a page like page_load, button_click events and so on. Where in the
codebehind would I put the creation of the object...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |