Re: classes in visualstudio
error mess might have slight diff
Re: classes in visualstudio
Welcome to codeguru. Please use code tags. Your code isn't very readable without them.
Code:
class crep{
public:
....
} CREP;
The class is names 'crep', not 'CREP'. This is usually done with structs, not classes.
Re: classes in visualstudio
caps lock gets used for types in visual studio any class union struct there is. it means that a class type is available at the pick of your choise. capslockers gave messages
[code][size=-10]_italic_
<main.coo>requiring ';' before cerro declaration[\size][\code]
Re: classes in visualstudio
Quote:
Originally Posted by
john wiley
file:cpterr.cpp
====================================================================
Code:
#include"cpterr.h";
#include <windows.h>;
void crep::mb(CHAR* msg, CHAR* ttl){
PSTR temp;
MessageBoxA(0, msg, ttl, MB_OK);
//if error code need restart, warn users
if (lstrcmpi(ttl, __TEXT("exit")))
MessageBoxA(0, "please shut down", ttl, MB_OK);
// return 0l;
}...
Replace your includes with
Code:
#include <windows.h>
#include "cpterr.h"
Quote:
Originally Posted by
john wiley
,and prototype in:cpterr.h
Code:
class crep{
public:
void *operator new( size_t stAllocateBlock, char chInit );
crep(void);
~crep();
//public:
DWORD getrr(DWORD ol,LPSTR nume2);//explicitare erori mci?////prototip elem. nou adaugat
void mb(CHAR* msg, CHAR* ttl); //message box
private:
int classe;
} CREP;
Add typedef before the class
Quote:
Originally Posted by
john wiley
Code:
#include "cpterr.h" //define fataleclass
main(void){
CREP cerro; //(extern) CREP cerro
....
cerro.mb("mesage for autostart record","title");
....
}
Add
Code:
#include <windows.h>
as the first line
Re: classes in visualstudio
were you the only soul th2kindly checked and run it too ? It needs further work by me to improve
Great now it works *)th$
. __--------_
. / >|< \|/, \
.| / \ |
.\ --______-' |
. \ -- ___¯ ,;
. \--______-'
Re: classes in visualstudio
You'll save yourself much headache later if you learn to leverage the string types defined in TCHAR.H and not explicitly call the A or W api's (i.e. don't call MessageBoxA, call MessageBox instead).
Re: classes in visualstudio
many thanx , now let`s move on. I got following error.............................
--------------------Configuration: main_win32 - Win32 Release--------------------
Code:
*Output Window
*Compiling...
*fonemtia_win32.cpp
*Linking...
*main_win32.obj : error LNK2001: unresolved external symbol "long __cdecl FreeDirectSound(void)" (?FreeDirectSound@@YAJXZ)
*main_win32.obj : error LNK2001: unresolved external symbol "public: void __thiscall crep::mb(char *,char *)" (?mb@crep@@QAEXPAD0@Z)
*main_win32.obj : error LNK2001: unresolved external symbol "long __cdecl WaveCloseWriteFile(struct HMMIO__ * *,struct _MMCKINFO *,struct _MMCKINFO *,struct _MMIOINFO *,unsigned long)" (?WaveCloseWriteFile@@YAJPAPAUHMMIO__@@PAU_MMCKINFO@@1PAU_MMIOINFO@@K@Z)
*main_win32.obj : error LNK2001: unresolved external symbol "int __cdecl WaveStartDataWrite(struct HMMIO__ *,struct _MMCKINFO *,struct _MMIOINFO)" (?WaveStartDataWrite@@YAHPAUHMMIO__@@PAU_MMCKINFO@@U_MMIOINFO@@@Z)
*main_win32.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall crep::getrr(unsigned long,char *)" (?getrr@crep@@QAEKKPAD@Z)
*Release/main_win32.exe : fatal error LNK1120: 5 unresolved externals
*Error executing link.exe.
choosing struct settled the solution; my class has option to store a function/procs such as crep.mb(), where ()is arg for function mb. I have fixed error by temporary using struct, now works ok.
late news is beyond compiler errors (now fixed ;) came up linker error. where is the problem in there?
Re: classes in visualstudio
Probably, you've got that stuff from one internet kiddie.
Otherwise, I could not explain so many shuffled horrors in just few lines of code.:)
First of all, try to get rid of C-style constructions like
Code:
class _CFoo
{
// ...
}CFoo;
as well as
Code:
typedef class _CFoo
{
// ...
}CFoo;
Note: C has not 'class' keyword but you can imagine replacing it with 'struct' to be a real C-geek. :)
In C++, the usual class (or struct) definitions look like this one:
Code:
class CFoo
{
//...
};
Simplu ca "buna ziua!" (simple like "good day!"). ;)
Besides, if using Visual Studio, a wizard can help you to properly add new classes.
Second, overloading the new operator there, has no sense. Simply, remove it.
Also WTH is that "please shut down"? Prompt the user for shut down because an MCI function has failed?
C'mon... let's be serious!
Re: classes in visualstudio
I do not use special symbols in classes definitions &only declared it as typedef "}CREP;" .
SPlitting functions in classes by scopes (one to report error in crep classe;another to display formatted messages by my template mb(,); and latter w/ headers in ext4.cpp) helps me centr3 macrofunctions. Then I use caption mess & code error ids using "resource wizard in visual environment."
Is there a way to pass limitations in visual environment (if)to have prototype declared in a file and function-body deffined in a file directly accesible from very file?iMy way was to declare headers main file, some headers in a place, other elsewhere and global declarations in another not so straighforward accesibe from the prototype file -cpterr.h ? ("cpterr.h" does not have #include<?> sattements and neither "cpterr.cpp".)
Re: classes in visualstudio
Quote:
Originally Posted by
john wiley
I do not use special symbols in classes definitions &only declared it as typedef "}CREP;" .
SPlitting functions in classes by scopes (one to report error in crep classe;another to display formatted messages by my template mb(,); and latter w/ headers in ext4.cpp) helps me centr3 macrofunctions. Then I use caption mess & code error ids using "resource wizard in visual environment."
Is there a way to pass limitations in visual environment (if) ...
Please clarify what do you mean with
- use special symbols in classes definitions
- SPlitting functions in classes by scopes
- use caption mess & code error ids using "resource wizard in visual environment."
- pass limitations in visual environment (if)
Re: classes in visualstudio
I did a small image:
[img]
http://www.freeimagehosting.net/t/93f19.jpg
[/img]
If you have the time read again and interpret it, pleass? Its a five files graph
Re: classes in visualstudio
Quote:
Originally Posted by
john wiley
Please, attach your image to your post.