|
I tried system("c:\\....exe") and ShellExecute("c:\....exe") but both of them shows a black DOS box.. I want do launch the program directly
|
|
|
|
|
|
I have Visual C++, Version 6.0. Old, I know, but I will purchase a new one based on what I learn about its ability for polymorphic overloading of operators.
I want to overload operators in a polymorphic fashion. The idea is to be able to create a sort of algebra of geometric objects. So, for example, I can easily overload vector operators for vector addition by overloading the + operator for that particular class, and the code will look like mathematical notation.
If however I want to overload operators for a class of objects, I must use a messy construction, depending on dereferencing pointers. The notation doesn't look quite like textbook notation.
This is because Microsoft C++ does polymorphism through pointers, not through the objects themselves.
I will explain by example:
I have two classes of objects: spline and cube. Both are based on class geom. I also have a matrix class. Code snippets follow:
class geom : public CObject {
public:
geom();
virtual ~geom();
DECLARE_SERIAL(geom);
void Serialize(CArchive& ar);
geom(geom&);
void operator=(geom& obj);
virtual geom operator *(matrix); // Right product by matrix
virtual geom operator*=(matrix&); // Right product by matrix
}; // class geom
class cube : public geom {
public:
cube();
virtual ~cube();
DECLARE_SERIAL(cube);
void Serialize(CArchive& ar);
geom operator *(matrix); // Right product by matrix
geom operator*=(matrix&); // Right product by matrix
// A cube has some vectors in it, which can be transformed by operator *
// overloaded for matrix multiplication
}; // class cube
class spline : public geom {
public:
spline ();
virtual ~ spline ();
geom operator *(matrix); // Right product by matrix
geom operator*=(matrix&); // Right product by matrix
// A spline has some vectors in it, which can be transformed by operator *
// overloaded for matrix multiplication
}; // class spline
I want to use matrix multiplication thusly:
spline sp;
spline sp_transformed;
cube cu;
cube cu_transformed;
matrix xformer;
sp_transformed= sp * xformer; // Comes out not really a spline- only a geom.
cu_transformed= cu * xformer; // Comes out not really a cube- only a geom.
What comes out is just the geom part. No amount of doodling with
geom(geom&);
void operator=(geom& obj);
will help.
However, if I use pointers, as follows, this works. But it is clumsy, and I also have to
worry about deleting the intermediate products:
class geom : public CObject {
public:
geom();
virtual ~geom();
DECLARE_SERIAL(geom);
void Serialize(CArchive& ar);
geom(geom&);
void operator=(geom& obj);
virtual geom *operator *(matrix); // Right product by matrix
virtual geom *operator*=(matrix&); // Right product by matrix
}; // class geom
class cube : public geom {
public:
cube();
virtual ~cube();
DECLARE_SERIAL(cube);
void Serialize(CArchive& ar);
geom *operator *(matrix); // Right product by matrix
geom *operator*=(matrix&); // Right product by matrix
// A cube has some vectors in it, which can be transformed by operator *
// overloaded for matrix multiplication
}; // class cube
class spline : public geom {
public:
spline ();
virtual ~ spline ();
geom *operator *(matrix); // Right product by matrix
geom *operator*=(matrix&); // Right product by matrix
// A spline has some vectors in it, which can be transformed by operator *
// overloaded for matrix multiplication
}; // class spline
spline sp;
spline sp_transformed;
cube cu;
cube cu_transformed;
matrix xformer;
sp_transformed= *(sp * xformer); // Messy
cu_transformed= *(cu * xformer); // Messy
So, my question is, does anybody know of a C++ implementation which supports the first kind of polymorphic overloading, which I might call "puristic"?
|
|
|
|
|
I'm currently in the process of writing an assembly, and I'm trying to test some of the code that I wrote. I'm wondering if it's possible to debug the code inside the assembly. Does anyone know if I can do this? If so, is there any documentation on this?
Cheers!
Kevin
|
|
|
|
|
I may be missing something, but...
run it under the debugger using either the mixed mode or managed debugger.
|
|
|
|
|
Hello friends,
I have a file containing:
1499,0508,00747522,13:56:22.289248,13:56:23.232780,50182289248,50183232780,-943532
600 lines like this
I declared a structure like this
struct data{
int c1;
int c2;
long int c3;
char c4[15];
char c5[15];
long double c6;
long double c7;
int c8;};
and in the main program
FILE *fp=NULL;
int i=0,j=0,k=0;
char c=NULL,cc=NULL;
fp = fopen("res.txt","r");
for(i=0;i<601;i++)
fscanf(fp,"%d, %d, %ld,",&c1,&c2,&c3);
for(j=0;j<15;j++){
fscanf(fp,"%c,",&c);
c4[j]=c;}
for(k=0;k<15;k++){
fscanf(fp,"%c,",&cc);
c5[k]=cc;}
fscanf(fp,"%E,",&c6);
fscanf(fp,"%E,",&c7);
fscanf(fp,"%d\n",&c8);
and when i tried to print cdata[i].c4,c5,c6,c7,c8 etc for some i value...Im getting garbage value...
Can anyone of you help me?
how to tackle that c4 and c5?
is it right to take long double for c6,c7?
thanx in advance...
Regards
|
|
|
|
|
I need to send data with using serial port. and i found AxMSComm can u explain what is AxMSComm and how we use it.
-------------------------------------------------------
haven`t sign yet
|
|
|
|
|
|
Thanks for the link. actually VS .Net 2003 beta doesn`t find
#using <axmscommlib.dll>
#using <mscommlib.dll>
using namespace AxMSCommLib;
using namespace MSCommLib;
unless i drag the AxMSComm from "Microsoft Communications Control" from toolbox menu
when i drag it
this->axMSComm1->Handshaking = HandshakingConstants::NoHandshaking; // no handshake is used
It doesnt find NoHandshaking function
what is the reason that VS 2003 .Net compiler doesn`t find that functions.
thanks!!
|
|
|
|
|
Hi there,
I have a strange thing happening with calloc/malloc. Here is my code:
...
double *a = (double*)malloc(Na*sizeof(double));
double *b = (double*)malloc(Nb*sizeof(double));
double *c = (double*)malloc(Nc*sizeof(double));
...
The problem is that the two pointers b and c point toward the same address. Anyone aware of this problem and how to fix it?? (I'm working under .NET2003)
Thanks a lot.
|
|
|
|
|
|
Yes, sorry for disturbance. Would that be in the Visual C++/MFC forum?
|
|
|
|
|
|
Hello...
I have a function called:
MyFunction(LPCVOID lpBuffer)
{
}
But my parameter is a String*, for example:
String* s = "Hello World";
Are there any possibilities to cast String* to LPCVOID ?
|
|
|
|
|
|
See System::Runtime::InteropServices::Marshal class.
|
|
|
|
|
You can't do a plain cast from a managed pointer to an unmanged one, you need to pin the managed pointer so the underlying object doesn't move during GCs.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi, I would like to know how to search through a file for specific words or phrases using VisualC++ 2003
-- modified at 7:38 Thursday 20th July, 2006
|
|
|
|
|
Load the file into memory and search then. It's easier and faster.
|
|
|
|
|
I currently have a COM component (and source) that talks to a printer and also a hardware port through a Vendor supplied DLL that makes fairly low level calls, and was wondering if there is a reference for displaying how to create a Managed Assembly in C++ that can performed the unmanaged calls, but present a nice .Net interface for the other developers. It does lots of GetProcAddress and
I would prefer not to interop to my existing COM Component, because I am trying to get a clean project.
I could possibly do it in C#, but wondering if it would be better in managed C++?
<br />
PORTOUT PortOut;<br />
PORTWORDOUT PortWordOut;<br />
PORTDWORDOUT PortDWordOut;<br />
PORTIN PortIn;<br />
PORTWORDIN PortWordIn;<br />
PORTDWORDIN PortDWordIn;<br />
SETPORTBIT SetPortBit;<br />
CLRPORTBIT ClrPortBit;<br />
NOTPORTBIT NotPortBit;<br />
GETPORTBIT GetPortBit;<br />
RIGHTPORTSHIFT RightPortShift;<br />
LEFTPORTSHIFT LeftPortShift;<br />
ISDRIVERINSTALLED IsDriverInstalled;<br />
...<br />
and then makes calls like this<br />
...<br />
<br />
LoadIODLL();<br />
PortOut(0x2E,(unsigned char) 0x87);<br />
PortOut(0x2E,(unsigned char) 0x87);<br />
PortOut(0x2E,(unsigned char) 0x07);<br />
PortOut(0x2F,(unsigned char) 0x07);<br />
PortOut(0x2E,(unsigned char) 0xf1);<br />
<br />
...<br />
<br />
hio = LoadLibrary("cashdrawerio.dll");<br />
if (hio == NULL)<br />
{<br />
return;<br />
}<br />
else<br />
{<br />
<br />
PortOut = (PORTOUT)GetProcAddress(hio, "PortOut");<br />
PortWordOut = (PORTWORDOUT)GetProcAddress(hio, "PortWordOut");<br />
PortDWordOut = (PORTDWORDOUT)GetProcAddress(hio, "PortDWordOut");<br />
PortIn = (PORTIN)GetProcAddress(hio, "PortIn");<br />
PortWordIn = (PORTWORDIN)GetProcAddress(hio, "PortWordIn");<br />
PortDWordIn = (PORTDWORDIN)GetProcAddress(hio, "PortDWordIn");<br />
SetPortBit = (SETPORTBIT)GetProcAddress(hio, "SetPortBit");<br />
ClrPortBit = (CLRPORTBIT)GetProcAddress(hio, "ClrPortBit");<br />
NotPortBit = (NOTPORTBIT)GetProcAddress(hio, "NotPortBit");<br />
GetPortBit = (GETPORTBIT)GetProcAddress(hio, "GetPortBit");<br />
RightPortShift = (RIGHTPORTSHIFT)GetProcAddress(hio, "RightPortShift");<br />
LeftPortShift = (LEFTPORTSHIFT)GetProcAddress(hio, "LeftPortShift");<br />
IsDriverInstalled = (ISDRIVERINSTALLED)GetProcAddress(hio, "IsDriverInstalled");<br />
<br />
}<br />
|
|
|
|
|
Hi there..
I'm currently writing a managed c++ application which adds user entered data (textbox) into a access database.
I have some problems with formatting the sql string in the right format.. this is the sql string:
String *sqlstr = S"INSERT INTO klanten (Naam, Adres) VALUES", textBox1->Text->ToString(), textBox2->Text->ToString();
When running the program I get the following error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
I don't know how to correct the sql string
|
|
|
|
|
vincent7_6 wrote: I don't know how to correct the sql string
Debug the application and get the sql string value. Then find out why it is not valid SQL. If you don't know SQL well enough to determine the problem, CodeProject has a SQL forum you get help from.
Also using SQL in this fashion makes the application vulnerable to "SQL Injection Attack".
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
SQL Syntax is:
INSERT INTO klanten (Naam, Adres) VALUES ('Whatever','Whatever')
But like led mike said, you should guard against:SQL Injection Attacks[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Using the designer to create the main form for an application generated the following code in the .cpp file:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
Application::Run(new DataForm(lpCmdLine));
return 0;
}
The DataForm class has a button which generates a new form:
linkedForm = new LinkedForm() ;
The LinkedForm class exists in the same namespace as the DataForm class.
What needs to be done to allow this child form to see public methods in it's parent, since a DataForm ptr cannot be declared globally? Are there any examples of parent/child form communications of this nature?
Thanks,
MrHonus
|
|
|
|
|
See the MVC (Model-View-Controller) design pattern. It is on Wikipedia. Forms are Views and should not be coupled. Views (Forms) should access a "Controller" to initiate action based on UI (User) events. Views subscribe to events exposed from the "Model" to be notified of data and/or "state" changes. Views then obtain the latest data to display from the "Model".
|
|
|
|
|