|
Well it's been a long time since I was last on here. More to the point, it's been a long time since I coded in C++. I have been consigned to the spineless world of VB6 for the last year and a half unfortunately. (Looks around for a sympathetic shoulder to cry on)
Anyway, I've got a small project on the go and there was something I just wanted to query on. Having been spoilt (and I don't mean that in a good way cos I've got sloppy) with zero-initialisation of basic types in VB6, I was wondering if there is a setting in Visual C++ 2003 compiler which forces the compiler to zero-initialise basic types? I seem to recall some compilers (like GNU ones) are able to be configured to do this. I know it's less efficient but I like being able to start using variables "clean" as it were. I know there is default initialisation defined by ANSI C++ which works like this:
int * someint = new int();
but that seems awfully awkward and looks like it'll cause headaches. Having to keep a lookout for pointer management of basic types seems like a pain. I just want to be able to configure the compiler so I can go:
int someint;
and know that after the declaration it'll be zeroed out. I know there is also memset, but it just makes the code messier.
Or perhaps I should just be a good boy and initialise everything explicitly?
|
|
|
|
|
I too was once a Basic programmer and will spend eternity ( well MAX_INT milliseconds at least ) repenting of my ways.
If you want default initialization done propoerly, you know what's coming, you'll have to do it yourself.
Here's one way.
<br />
struct Int<br />
{<br />
Int(){ i = 0; }<br />
int i;<br />
};<br />
Of course now you've done that you might as well go the whole hog and make it a fully fledged class with operators and conversion casts and stream handling, default conversion to a string for tracing and ...
whoops we've just recreated .NET System.Int32 Aaaaaaarrgh
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Yeh lol. OK, well I thought there might be a way but clearly not. Unfortunately, the project is Win32 so can't use .Net classes. Guess I'll just do it all explicitly. I've forgotten all my good C++ habits in the last two years. Thanks for the help.
|
|
|
|
|
hi...
am doing client server communication with CSocket.
shall i do communication between server and client without CSocket or using Casynchronous socket?
Is it possible?
if yes, what metheod i can use? please explain somewhat brief...
can anyone help me?
regards,
paulraj
|
|
|
|
|
The magic is all around you...[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
hai,
have u heard about "Pipes"...using this we can create client server communication.
regards,
mani
Born to win...!
|
|
|
|
|
hi...
can you tell something briefly...
thanks in advance...
paulraj
|
|
|
|
|
|
gnanapaul wrote: shall i do communication between server and client without CSocket or using Casynchronous socket?
Is it possible?
While it is possible, it is not recommended. Read one such comment by Dr. Newcomer here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I m new in proggraming, i m working on Visual C++ 2005, in my project i want to use Access database for storing data.
In my project i want store the user enterd values in database and reterived it any time.
but i dont know any thing about Access/Database and how to use database for storing data.
please any one can help me for this.
thanks in advance.
|
|
|
|
|
I don't know much about databases but when I did use it once I found caaadoclass1[^] article very useful. It will hide all the dirty details, all you have to do is create a database using access and supply a connection string to the code in the article.
-Saurabh
|
|
|
|
|
thanks for help but there is error in downloaded program.
|
|
|
|
|
Can you provide more details about the error? And also which compiler are you using.
-Saurabh
|
|
|
|
|
error is::error C2668: 'pow' : ambiguous call to overloaded function
and i m using Visual c++ 2005 .
|
|
|
|
|
Yeah those are because most like arguments of pow are not compatible. Check if is code like this
double x = 10;
pow(5, x);
In this case change it to
pow(5.0, x).
And just FYI when you get a warning or error in VC++ you can look for it in MSDN in detail and ways to fix it. Easiest way to do this is click on the error or warning number in the Output Window and press F1.
-Saurabh
|
|
|
|
|
|
i m check this code they r using ActiveX control for table,but i using simple List control.
so this example is nat make me clear,please tell sumthing else.
thanks for help.
|
|
|
|
|
Try also the SQL/ADO/ADO.NET forum [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
So have you already created the database using Access itself, or are you wanting to do that via code?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
no i have no idea about this please tell me any thing which helps me.
|
|
|
|
|
ThatsMe. wrote: no i have no idea about this
How can you not know if you've already used Access to create the database or if you are wanting to do it via code?
ThatsMe. wrote: please tell me any thing which helps me.
How can I possibly know what information to provide you when you are having difficulties answering my questions?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You can see a lot articles about Databse(and Access) on the codeproject,did you seee that section?
|
|
|
|
|
Hi,
How do you make assembly wrappers for a GNU compiler? I am confused as to how to make an assembly wrapper/macro. Upon my searches/readings, I think that there is no standard way to do it, and that it depends on your compiler/assembler.
My problem is that I have a few lines of assembly code that I keep using for several functions.. in C/C++, you would just make macros for those lines of code. How do you do that for assembly? Any pertinent feedback would be appreciated. Thanks, let me know.
Luis_the_Code
|
|
|
|
|
Yes,we can use Macro in C/C++. It seems that you know ASM,if so,there is Macro syntax,too.
And if you have a few ASM lines would be used for several function,if in C/C++,I want to say,you can use Macro too,using it like this
#define ASM_MACRO __asm{ \ //for multiline Macro
... \ //there are some asm code lines
}
I wish it will help to you.
Regards.
|
|
|
|
|
I'm investigating garbage collection methodologies for C++.
I've been reading about smart pointers, and they seem to make sense, except for this one point that I cannot understand:
In the case of a container object, such as a hash table or even just an array of smart pointers, how do the pointers know that they are still "alive" once they are put into the container?
Thanks if someone can help me understand how that works.
“Cannot find REALITY.SYS...Universe Halted.”
~ God on phone with Microsoft Customer Support
|
|
|
|