|
WHY CONSTRUCTOR CAN'T BE VIRTUAL FUNCTION BUT DESTRUCTOR CAN BE.
RAJINDER SINGH SIKH
|
|
|
|
|
|
Dare I ask...
Why?
To create an object of the base type and have the compiler choose a derived class for me?
|
|
|
|
|
DON'T YELL !!!
Also, ask in the right forums next time. This is the MANAGED C++ forum.
|
|
|
|
|
Take a step back, and think about it! Virtual functions are called from a list of function adresses. When you create a new class, the constructors are called first, starting with the base class constructors. Each Base class constructor edits the virtual function table. When your class is constructed, it is there for you to use.The same happens in the oposite direction, when your class is destroyed. You cannot have virtual constructors, because they would have to be called before the virtual function table could have been constructed. It is a case of chicken or egg first.
LateNightsInNewry
|
|
|
|
|
Hi,
I´m pretty new in C++... and would like to get some help.
I´m connecting a device (a condutivimeter) to my RS232 COM1, and using BIOSCOM to comunicate with it, but I just can´t. (i just need to read from the port)
I´ve already done it with my other device (wich is a balance).
The device (condutivimeter) works with:
Baud rate 4800
Handshake: CTS/RTS + Xon/Xoff(this is the only difference between the devices)
Data bits : 8
Parity: none
Stop bit : 1
If somebody has some idea...
Thanks a lot
bruno Garcia
|
|
|
|
|
You posted in the (Managed) C++/CLI forum. I think you want to post this in the Visual C++ / MFC forum. People who can answer your C++ problems don't always come here. So, to better your odds of getting an answer, please post in the Visual C++ / MFC forum.
|
|
|
|
|
Hi every one,
I don't know how can I create wrapper class,wrapper code,.. in C++,if anyone knows please tell me step by step or send me sample code or link for learning.
yours sincerely ,
Orchid
|
|
|
|
|
Normally, you would have the wrapper class in an assembly. Also, I wrote the class methods inline for clarity only. This class CppWrapper is only a simple example. Marshalling can get a little complicated but it is quite easy most of the time. There is a lot of information on the internet about this, especially, written for Visual Managed C++ 2003.
using namespace System;
using namespace System::Runtime::InteropServices;
#include <iostream>
ref class CppWrapper
{
public:
void Print(String ^str)
{
IntPtr ptr = IntPtr::Zero;
try
{
ptr = Marshal::StringToHGlobalUni(str);
std::wcout << static_cast<wchar_t*>(ptr.ToPointer()) << std::endl;
}
catch (Exception ^ex)
{
Console::WriteLine(ex->Message);
}
finally
{
if (ptr != IntPtr::Zero)
Marshal::FreeHGlobal(ptr);
}
}
};
int main(array<System::String ^> ^args)
{
String ^str = L"Hello, World!";
CppWrapper ^wrapper = gcnew CppWrapper;
wrapper->Print(str);
return 0;
}
|
|
|
|
|
Dear George,
Thanks a lot for your help,
The sample code was very useful for me.
thank you again,
yours sincerely ,
Orchid.
|
|
|
|
|
Hello,
I'm a newbie in computer programming.
I'm looking for a program help me to change file attributes(Created time,Modified time and last access) like FileDate By T.YogaRamanan.
Here is link :
http://www.codeproject.com/file/FileDate.asp[^]
But I want to ignore its user interface.(No Dialog box , No Text box)
I want to choose file as coding and change file attribute as coding too.
I have tried to read source code of FileDate above.
I still can't do.
Can you help me ?
Thank you.
|
|
|
|
|
Well, the article, http://www.codeproject.com/file/FileDate.asp[^], was written in unmanaged C++ using MFC/Win32. So, is your question directed toward unmanaged C++ (then, you are in the wrong forum) or C++/CLI (Managed C++)?
|
|
|
|
|
toeh wrote: But I want to ignore its user interface.(No Dialog box , No Text box)
Then what is the problem.
U have to just take/use
int SetFileDateTime(char *szFilePath,
FILETIME ftCreated,
FILETIME ftModified,
FILETIME ftAccessed)
just copy that function or call that directly from ur module.
regards,
Divyang Mithaiwala
System Engineer & Software Engineer
|
|
|
|
|
Hi,
My name is aditya. i am a BE student in mechanical engg. now one of the subject that i have is CAME(Computer application in mechanical engg.). So i have C++ papers in which some typical questions are asked. if u could please post me the solutions to these problems it will be greatful.
1.Use concept of operator overloading to add or multiply 4*4 matrix of user inputs.
2.Use class matrix to read store display and perform multiplication operation between 2D matrix size user defined. Use 'new' and 'del' operator for creating and destroying matrix objects.
3.To draw a line of user defined length. using 'inheritance' show modification in this code to draw a rectangle of user defined dimensions.
4.A small calculator which performs +,-,*,/, and displays results only ater = key is pressed. Also displays the answer in scientific notation.
Pls i beg u to solve this problem.
My email id is- ads99free@yahoo.co.in
I need these solutions by saturday.i.e.18th november.
![Sigh | :sigh:](https://www.codeproject.com/script/Forums/Images/smiley_sigh.gif)
|
|
|
|
|
I suggest you hire a tutor, bud. I and many others aren't going to do your homework.
|
|
|
|
|
Dude, if you're not smart enough to ask in the right forum, and you're not smart enough to try and do your own homework, then perhaps you just need to apply at burger king.
|
|
|
|
|
If you get people to do your work for you, how do you expect to find a job when/if you graduate. That's the whole point of getting your degree right? To find a job?
You need so show some work on your own behalf before people asre willing to help you out.
|
|
|
|
|
hi Everybody
i planned to do soft in Borland C++
and i need to take information from Sound Card
and i've problem in findin appropriate object(component) which enables me to take info from Sound Card
please help
thanks..
Nurbek
|
|
|
|
|
You are in the wrong forum! (Managed) C++/CLI questions are welcomed!
|
|
|
|
|
so to which forum should i've written...
|
|
|
|
|
Actually, there is no general C++ forum here. IMHO, the Visual C++/ MFC forum would be your best bet since some developers may have had some experience with Borland. Otherwise, does Borland have message boards?
|
|
|
|
|
I have a service app skeleton created by the app wiz.
I'm a vc6 mFC guy, so i cudn't really figure out how a service's flow is.
MFC CWinApp::ExitInstance is called only after m_pMainWnd is closed. But for a service, After OnStart what happens? OnStop is invoked only when the service is stoped by the service manager? where am i to write my code? do we have a message loop or anything of the sort? idleprocessing?
pls tip me on these areas
thanks
snexxxxt
|
|
|
|
|
|
Hi everyone,
I created a project in VC++ (Class Library project in visual studio 2005) and I would like to use it in VB .
I defined 2 functions in classlibrary that one of them uses simple data type such as int,bool,.. in input and return value and other one uses data type such as char * .
When I use simple data type ,there is not any problem and I can call the function in vb successfully but when I use another data type such as (char * ,..)I can not call it and even I can not see the function in vb.
My question is about data type conversion between VC++ and VB.
My code is same as below :
//==============================
MyClassLibrary.h
#pragma once
using namespace System;
namespace MyClassLibrary{
public ref class InitCard
{
public :
bool VerifyPin(char *) ; //I can not see this function in VB
bool SetCardAccessKey(int); //I can see and use this function in VB successfully .
};
}
//======================My VB code is same as below :
Imports MyClassLibrary
Dim Jvm_offcard As New MyClassLibrary.InitCard
Jvm_offcard.SetCardAccessKey(2);
//Jvm_offcard.VerifyPin("1234") //there is an error on this line
I would like to know how can I use data type such as (char *,byte array ,string) between VC++ and VB code.
I would appreciate for any help .
Yours sincerely,
Orchid
|
|
|
|
|
char * is an unmanaged data type. Thus, VB.NET will not see it. You can use char * in C++/CLI because it was designed to handle unmanaged code. If you want to use char * with VB.NET, you will have to wrap the code and use marshalling with C++/CLI to bridge the managed and unmanaged worlds.
|
|
|
|