|
1) You lost some "<"s and ">"s in your post. Could you modify it with the formatting buttons below?
2) Could you make your question short instead of posting the entire code?! Thanks!
Maxwell Chen
|
|
|
|
|
Please post only the relevant code snippet (e.g., a dozen lines or so), and utilize the <pre> tags.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
There are a number of problems:
1. The class definition needs to go in file student.h, the implementation details go in student.cpp
2. Missing semi-colon after the second constructor in the class definition
3. Missing semi-colon after the closing brace in the class definition
4. When declaring a vector you need to specify the type that is contained, i.e.
vector<Student> StudendList
I think that this is likely just the problem with the angle brackets in post
5. The comma operator does not do what you think it does in
string student::getName()
{
return (first, last);
}
It evaluates the first expression (which doesn't do anything) and then returns the second expression. So this expression merely returns the last name. Assuming that you wanted to return the full name I expect that you want something like:
string student::getName()
{
return std::string(first).append(",").append(last);
}
There are other errors (e.g. misnamed and missing variables) but I'm sure you'll be able to find them
Might I suggest that you try a more incremental approach to producing code. Write a small bit of code, get it to compile and test it. Once that works add some more functionality and go through the cycle again. Even the most experienced programmers work this way
-- modified at 11:47 Monday 20th August, 2007
Graham
My signature is not black, just a very, very dark blue
|
|
|
|
|
Hello everyone,
I think for any platform (no matter whether on the platform, multibyte character or wide character is used as default encoding approach, for example, on Windows CE wide character is used as default encoding approach, i.e. UNICODE or _UNICODE is defined, and on Windows desktop platform, multibyte character is used as default), I could achieve the same function for any platform by either,
1. invoking fopen and pass file name encoded as multibyte character, no matter whether multibyte character or wide character is used as default encoding approach;
2. invoking wfopen and pass file name encoded as wide character, no matter whether multibyte character or wide character is used as default encoding approach.
thanks in advance,
George
|
|
|
|
|
So what's your question/problem?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David,
My question is, I want to know whether my understanding is correct for the two points,
(for any platform (no matter whether on the platform, multibyte character or wide character is used as default encoding approach, for example, on Windows CE wide character is used as default encoding approach, i.e. UNICODE or _UNICODE is defined, and on Windows desktop platform, multibyte character is used as default), I could achieve the same function for any platform by either)
--------------------
1. invoking fopen and pass file name encoded as multibyte character, no matter whether multibyte character or wide character is used as default encoding approach;
2. invoking wfopen and pass file name encoded as wide character, no matter whether multibyte character or wide character is used as default encoding approach.
--------------------
regards,
George
|
|
|
|
|
Why not just use _tfopen() and not have to worry about it?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David,
I just want to make a study and research and I want to use the preferred function independent of whether UNICODE or _UNICODE is defined.
When UNICODE or _UNICODE is defined, _tfopen() will be defined to wfopen, and when UNICODE and _UNICODE are not defined, _tfopen() will be defined to fopen.
My purpose is, I want to use fopen and wfopen independent of whether UNICODE or _UNICODE is defined. For example, when UNICODE is defined, I want to use fopen.
Could you read and comment my original question to see whether my understanding is correct?
regards,
George
|
|
|
|
|
George_George wrote: ...I want to use the preferred function independent of whether UNICODE or _UNICODE is defined.
Hence my suggestion to use _tfopen() .
George_George wrote: For example, when UNICODE is defined, I want to use fopen.
Which is exactly what happens. Check the preprocessor output, and you'll notice that fopen() is being used.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David,
How to check preprocessor output in Visual Studio 2003?
regards,
George
|
|
|
|
|
George_George wrote: How to check preprocessor output in Visual Studio 2003?
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, your understanding is correct. However, these things are taken care by "Using Generic-Text Mappings". For example, if you use _tfopen (Generic-text routine name) and if SBCS (_UNICODE & MBCS Not Defined) then it will convert as fopen, if MBCS defined - fopen and if UNICODE defined - _wfopen.
Please refer http://msdn2.microsoft.com/en-us/library/7dzey6h6(VS.80).aspx[^] for more information.
Regards,
Paresh.
|
|
|
|
|
Thanks Paresh,
I want to confirm that, for any Windows platform, no matter whether UNICODE or _UNICODE is defined, we could invoke fopen and wfopen freely. Right?
For example, when UNICODE or _UNICODE is defined, we could still use fopen and pass multibyte encoded characters. Right?
regards,
George
|
|
|
|
|
FILE *fopen( const char *filename, const char *mode );<br />
FILE *_wfopen( const wchar_t *filename, const wchar_t *mode );
The fopen function opens the file specified by filename. _wfopen is a wide-character version of fopen; the arguments to _wfopen are wide-character strings. _wfopen and fopen behave identically otherwise.
If the symbol _UNICODE is defined for your program, parameter "filename" is of type pointer to wchar_t, a 16-bit character type; otherwise, it is of type pointer to char, the normal 8-bit character type.
Please refer below websites for more information,
http://www.i18nguy.com/unicode/c-unicode.html[^]
http://msdn2.microsoft.com/en-us/library/yeby3zcb(VS.80).aspx[^] - Look at "Generic-Text Routine Mappings".
Regards,
Paresh.
|
|
|
|
|
Thanks Paresh,
I think I can use fopen even if I defined UNICODE, and pass parameter in multibyte character, right?
regards,
George
|
|
|
|
|
I've the following problem:
the client invokes some functions on the server side, which takes a lot of time (a few minutes) to answer. I believe it depends on the timeout. How can I put it up?
I've the following exception:
"Caught exception:
Type: class RCF::Exception
What: [30: client read timed out][0: No sub system][0: ][What: ][Context: ..\rcf-09c\src\rcf\TcpClientTransport.cpp(275): void __thiscall RCF::TcpClientTransport::bsdRecv(const class RCF::ByteBuffer &,__w64 unsigned int): : Thread-id=688 : Timestamp(ms)=41594734: THROW : class RCF::Exception : [30: client read timed out][0: No sub system][0: ][What: ][Context: ]: bytesToRead=4,..."
Many thanks,
Daria
|
|
|
|
|
Does anyone know of a C++ equivalent (preferably *not* MFC) of .Net's FileSystemWatcher?
[edit] never mind, after a bit more searching, I stumbled upon this [^][/edit]
Last modified: 12mins after originally posted --
|
|
|
|
|
Hi
I'm getting streaming data to the program I'm writing and I need to update the data constantly. I'm currently just doing a switch statement to determine what needs to be updated and then after the switch I have UpdateData(false); This works but it will not allow me to enter values into over boxes in the display as it is constantly being updated. Is there a way to update just the single box value and not the whole display?
Thanks
Simon
|
|
|
|
|
simoncoul wrote: Is there a way to update just the single box value and not the whole display?
Sure, just use ClassWizard (Ctrl+W) to assign a control variable to each control on the dialog. For edit, static, and button controls, use SetWindowText() . For listboxes and comboboxes, use AddString() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hey thanks for the quick reply, but the SetWindowText asks for a LPCTSTR as the argument but I need to do integers and sometimes floats. Can I just cast it?
Thanks again
|
|
|
|
|
There are functions for appropriate conversion, for example itoa, ltoa.
Or, if you are using CString:
long var =12345;
CString strVar;
strVar.Format( "%d", var );
MS
|
|
|
|
|
simoncoul wrote: Can I just cast it?
No. Use:
char szData[16];
int nValue = 12345;
sprintf(szData, "%d", nValue);
...
double dValue = 987.01;
sprintf(szData, "%f", dValue); By chance are you using MFC?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes I am, does that make this easier?
|
|
|
|
|
simoncoul wrote: does that make this easier?
Not necessarily easier, but slightly more elegant and efficient:
CString strData;
int nValue = 12345;
strData.Format("%d", nValue);
...
double dValue = 987.01;
strData.Format("%f", dValue);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for all the help guys!
|
|
|
|