"The hard part is when part of the code would like in DLL form (i use visual
studio 2008). So 'by force' i must learn C++ and find plenty difficulties like
pointer and etc. I hope this group is where the place i will familiar with C++
faster."
Why would you have to learn C++ to understand how to write a Windows DLL? I'm
familiar with loading DLLs with LoadLibrary() and exporting functions from DLLs
using GetProcAddress(). But you don't need to know C++ to use them. They are C
functions. I have not worked with the Windows API lately so, maybe I'm missing
something. Are you using a C++ GUI framework?
There is a way to export C++ class objects from Windows DLL and Unix shared
libs as well. The advantage of exporting objects instead of a single function
is that you export a bunch of functions from DLL or shared lib at one time. The
object could represent a Windows GUI widget or back-end application utilities
etc. I would not suggest this strategy until you have a good understanding of
how C++ implements its polymorphic features. You would use the same C/Windows
functions to initiate it. I did this many times, but have not seen much of it
lately.
"Regarding pointer, i would like to ask for good reference to understand
pointer in C++ better because i had a lot of problem handling string (handling
char and char*) "
Most C++ primers will give you an intro to the std::string type. You probably
can find good tutorials online in pdf form. In C++ the std::string class can be
used to safely perform most char* operations. You should look at the online
documentation for C++ std::string.
Instead of using char* str = "My string" or char str[9]. You can use,
std::string myString = "My String";
myString += " more data";
and operate on the string data using the methods of std::string. Also, instead
of using pointers use references. C++ references are implemented using pointers
anyway. It's just a cleaner way of dealing with pass by reference situations.
So, when you want to operate on the actual string (not a copy) inside a
function the signature would be:
void func(std::string& inString);
Basic C++ is easier than C programming. The complexity is introduced when using
object-oriented features, data abstraction, polymorphism, inheritance etc.
Focus on the fundamentals while you're learning.
C++ mangle the names of functions to avoid ambiguities from function
overloading and member functions in different classes . Make sure you
understand how and why you specify the calling convention using extern "C" so
C++ won't mangle C function names.
#ifdef __cplusplus
extern "C" {
#endif
#include "oldcstuff.h"
#ifdef __cplusplus
}
#endif
You'll still need your low-level C knowledge to get the procedure addresses
from your DLL and work with other C/APIs. When using classes in your code keep
them simple and use static member functions when you need to make your C++
class method work with C functions, for a Windows callback for example. You can
also encapsulate your DLL operations in C++ classes to make your code safer and
easier to understand.
Until you understand the C++ language you'll have efficiency issues you that
you might not realize, caused by copying, temporary objects and compiler
generated code.
I hope this was helpful.
Best Regards,
Jim Smith
--- On Mon, 6/29/09, victory1_veeco <[email protected]> wrote:
From: victory1_veeco <[email protected]>
Subject: [c-prog] Introduction
To: [email protected]
Date: Monday, June 29, 2009, 5:18 PM
Hello,
my name is Victor, i just join the group today.
I came to C++ 'by force'. Basically i'm a PHP and C Programmer. Recently my
friend ask me to learn a new C derivative language, call MetaQuotes Languages
(MQL).. it is an easier task for me.
The hard part is when part of the code would like in DLL form (i use visual
studio 2008). So 'by force' i must learn C++ and find plenty difficulties like
pointer and etc. I hope this group is where the place i will familiar with C++
faster.
Regarding pointer, i would like to ask for good reference to understand pointer
in C++ better because i had a lot of problem handling string (handling char and
char*) , is there more "dirty" way to do it, like having:
char *theText="this is "+ " the Text "+" i made";
rather than
char *theText="this is ";
char result[100];
strcpy(result, theText);
strcat(result, " the Text");
strcat(result, " i made");
[Non-text portions of this message have been removed]