|
Christian Graus wrote:
This is not valid C++, you need to include iostream without the h
I think in borland, this is valid (if I remember my classes correctly, because we were using borland ).
Christian Graus wrote:
and hte include should be in < > instead of quotes
The difference between "" and <> is the search locations for the file. With "", the compiler will first look in the current directory to find the file then in the include directories. With the <>, it will be the opposite.
Christian Graus wrote:
I don't think this syntax is correct. I think you need to lose 'public'.
The syntax is correct.
|
|
|
|
|
Regarding iostream.h, VC up to 2005 offers this header as well, but it's still not valid C++. It's finally removed in VC2005, and any half decent C++ programer should not have used it for at least 5 years now.
cedric moonen wrote:
The difference between "" and <> is the search locations for the file.
Yes, I know
cedric moonen wrote:
The syntax is correct.
OK, then it's definately not valid C++, no matter what some compiler hack allows
Christian Graus - Microsoft MVP - C++
-- modified at 18:06 Thursday 8th September, 2005
|
|
|
|
|
mcnu wrote:
result(int a,float b,float c,float d):st_Det(a),st_Mark_Det(b,c),st_Sprt(d)
This is not really a good design practice because normally, this must be the st_Mark_Det constructor that should call the st_Det constructor instead of result calling directly it. You can add a new parameter in st_Mark_Det constructor and use this new parameter to call the constructor of st_Det inside the constructor of st_Mark_Det.
I never tried what you did so I don't know if this could be the source of an error or not. But still, this is not really good looking.
Otherwise, your code looks good...
|
|
|
|
|
i feel your correct and i wrote what you said i added one new parameter in <B>st_Mark_Det<B> constructor to intialize the member varible in the <B>st_Det<B> and that not giving any errors.
and my atual error is what i said earlier
after compiling my program it gives compiler error like this <B> st_Mark_Det must be previously defined class or sturuct<B>
#include <iostream.h>
#include <conio.h>
class st_Det
{
protected:
int rol_no;
public:
//st_Det(){}
// st_Det(int a){rol_no=a;}
void put_No(void){ cout<<"\nRoll No :"<<rol_no<<endl;}
};
class st_Mark_Det:public st_Det
{
protected:
float sub1,sub2;
public:
// st_Mark_Det(){}
st_Mark_Det(float a,float b,float c){rol_no=a;sub1=a;sub2=b;}
void put_Mark(void){cout<<"\nMarks\n SUBJECT1 "<<sub1<<"\nSUBJECT2 "<<sub2;
};
class st_Sprt
{
protected:
float score;
public:
st_Sprt(float a){score=a;}
void put_Score(void){cout<<"\nScore In Sports\n"<<score<<endl;}
};
class result:public st_Mark_Det,public st_Sprt
{
float total;
public:
result(int a,float b,float c,float d):st_Mark_Det(a,b,c),st_Sprt(d)
{total=0;}
float sum(){total=sub1+sub2+score;}
void display (void){ put_No();put_Mark();put_Score();cout<<sum();}
};
int main()
{
cout<<"\nEnter Student Roll NO:\t";int a;cin>>a;
cout<<"\nEnter Marks In tow subjects";float b,c;
cin>>b>>c;
cout<<"\nEnter Score In Sports :\t";float d;cin>>d;
result s1(a,b,c,d);
result.display();
getch();
return 0;
}
Regards
cnu...
|
|
|
|
|
At which line is the error displayed ? (Don't post the line number but the complete line). Post also the exact error message.
|
|
|
|
|
Geeez, pretty difficult to find this error !
The error is at this line:
class st_Mark_Det:public st_Det<br />
{<br />
protected:<br />
float sub1,sub2;<br />
public:<br />
st_Mark_Det(float a,float b,float c){rol_no=a;sub1=a;sub2=b;}<br />
void put_Mark(void){cout<<"\nMarks\n SUBJECT1 "<<sub1<<"\nSUBJECT2 "<<sub2;<br />
};<br />
You forgot the '}':
void put_Mark(void){cout<<"\nMarks\n SUBJECT1 "<<sub1<<"\nSUBJECT2 "<<sub2; }
That's one reason why putting all the code in one single header file is so bad: it's almost impossible to spot the corresponding '}'. Also, you should really use a better way of 'formating' your text. The purpose here is not to have the smallest number of lines but to have a code that is readable
|
|
|
|
|
It is working now,
THANK YOU VERY MUCH
AND THANKS FOR YOUR SUGGESTION I AM REALLY CONSIDER THAT
Live life happily until your last second
-- modified at 8:44 Thursday 8th September, 2005
|
|
|
|
|
Hello cedric monen this is mcnu
Thanks for the help
and Thanks for your suggestion that is really helpful to me
regards
cnu
Live life happily until your last second
-- modified at 9:28 Thursday 8th September, 2005
|
|
|
|
|
You're welcome
|
|
|
|
|
Hi all,
Can anyone help me? I need to store a windows forms as a bitmap file i.e. when the form closes save the form as an image.
Is this at all possible? I suppose I'm looking for print screen like functionality but I only want to capture the form itself.
Hope it makes sense.
Thanks all.
Richard
|
|
|
|
|
Richard,
I'm surprised that no one responded to this question. It is definitely possible to save a screen display to the bitmap format, as you are probably aware, most games have this capability built in.
There is an article right here on CodeProject that demonstrates this: Screen and Form Capture with Managed C++[^]
You may find that this is not the best possible solution, for a number of reasons. But, if it is adequate for your needs, who cares, it's simple and straightforward.
05
|
|
|
|
|
Hi there.
I downloaded a matrix arithmetic library, Newmat10, and are struggling to get it to work. The author says that it would work fine with MS Visual Studio 2003, which is what I am using.
The library consists of a lot of cpp files which have to be compiled. This part I get right. Then all I have to do is include the main header file >> newmatap.h, in the project where I want to use the matrix functions.
So I include the header file in the project where I want to use the functions and it compiles. But the moment I use one of the functions of the library, I get a lot of error messages that looks like this:
TestNewMat.obj : error LNK2019: unresolved external symbol "public: __thiscall Matrix::Matrix(int,int)" (??0Matrix@@QAE@HH@Z) referenced in function _main.
What am I doing wrong?
The author said something about it being best to store the resulting object files ( the ones you get when you compile the source files of the library) as a library. How does that work?
Any help would be appreciated!!
Thank you.
|
|
|
|
|
BenPage wrote:
The library consists of a lot of cpp files which have to be compiled
Do you compile them as a separate library ? Or do you want to add all the files to your project ?
BenPage wrote:
What am I doing wrong?
It's normal that it doesn't work: you have just included the header files in your project thus the linker doesn't find the 'code' for the functions. You have two solutions: either include the .cpp to your project also OR, if you want to use that in a separate library, go in the project settings (don't remember exactly where) and you have somewhere to tell that your project uses the library you compiled (don't forget to copy it to your project folder).
Hope this helps
|
|
|
|
|
how to convent variables from "String* " to "unsigned char *"?
&
how to convent variables from "unsigned char * " to "String *"?
Thank you very much!
|
|
|
|
|
Did you take a look at the Marshal.StringToPtrAuto and related methods?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
thanks for your prompting,
:(but i can't find the Marshal.StringToPtrAuto In neither Google Search or CP Search,
so can you tell me how to find it ?
Thank you very much.;)
|
|
|
|
|
Hello everyone!
OK, I just got into C++, and I need help with replacing text within a string... I'm looking for something like:
strreplace(charArray, oldValue, newValue);
The replace() function in the string class is hard to understand... Can anybody tell me what to do? Thanks!
BTW: The program I'm making is gonna be awesome when it's done!
And I'm on Borland's compiler. :P
Sulfurik K. Nosferathus (Darth_Sulfur)
www.SulfurMidis.com
www.SulfurSoft.tk
http://www.BeepXtreme.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 17:58 Monday 5th September, 2005
|
|
|
|
|
Darth_Sulfur wrote:
he replace() function in the string class is hard to understand... Can anybody tell me what to do?
string& replace(size_type pos, size_type n, const string& str);
Delete a substring from the current string, and replace it with another string.
string str14 = "abcdefghi";
string str15 = "XYZ";
str14.replace (4,2,str15);
cout << str14 << endl; // "abcdXYZghi"
I got that from google. It's pretty clear, you need to know the location and length of the string you want to replace. You could easily write a helper function that finds these things, and does the replace in the manner you're hoping.
Good luck !!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hard to understand ?
hum, let's see what the MSDN[^] tells us...
as you can see, there are 10 overloads of the function. choose the you you find the best for what you need, then, pass it the parameters it's waiting for (be careful of the type so...
the overload christian show you is the first one :
basic_string& replace(
size_type _Pos1,
size_type _Num1,
const value_type* _Ptr
);
_Pos1
The index of the operand string at which the replacement begins.
_Num1
The maximum number of characters to be replaced in the operand string.
_Ptr
The C-string that is to be a source of characters for the operand string.
i hope you understand better the doc...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Darth_Sulfur wrote:
C# is SOOOOOOOOOO much easier than C++!
nop, C# is better than Managed C++... here is the difference ;P
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
I have a C# project that needs to use a C++ SDK, so I'm trying to write a MC++ dll to act between them. At first, this was fine, but the problem is, the SDK defines a number of function pointers for callbacks. The objects I pass through complain that they are __gc type instead of type, and the pointers themselves complain that they are not __stdcall, which I assume means that the .NET stuff has it's own calling convention. However, I'm not that knowledgable when it comes to dlls, and I sure have never used MC++ before. I tried putting __nogc at the head of the class, that fixed all my errors, but gave me a new one, telling me I can't do that. What's the best way for me to proceed here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
...For those of you who are interested, this inquiry reaches a dramatic conclusion over at the Microsoft Technical Forums. I'm just SO HAPPY that I didn't make a TOTAL ASS out of myself, by attempting to offer some advice about something,...WELL, OK, BYE,...
cgraus[^]
And, More Analysis[^]
-- modified at 19:29 Tuesday 13th September, 2005
|
|
|
|
|
|