|
|
Maybe the compiler gets confused by your included header files.
Try to use:
<string> instead of <string.h>
<fstream> instead of <fstream.h>
<iostream> instead of <iostream.h>
...
And avoid mixing them up.
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
Something else is at play here. This works fine for me:
#include <fstream.h>
void main( void )
{
ofstream hours("c:\\file.txt");
int day = 20;
hours << day << endl;
}
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Yes, this problem is really a bit strange...
On my system the following code causes a C2679 error:
#include <string>
#include <fstream.h>
int main(int argc, char** argv)
{
ofstream hours("Hours.txt");
hours << "Hallo" << std::endl;
return 0;
}
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
Writing string is different than writing int (your original problem). The ofstream class does not support writing string data. You have to provide that yourself:
#include <fstream>
std::ofstream &operator<<( std::ofstream &os, const std::string &str )
{
os << str.c_str();
return os;
}
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
We have a programming assignment that goes like this
1. Write the definition and implementation of a Date class.
2. Write the definition and implementation of a Railcar class. Railcars have:
- identification number (string);
- kind (enumerated type: box, flat, hopper, tank);
- capacity (double)
- date of manufacture (Date)
3. Write a program that reads in data from a text file (whose name is specified by the user) containing Railcar data, where each line contains the data for one car. The program should print a report with each line containing all of the data for a Railcar followed by a summary of the number of cars in total and the number of each type of car.
I dont know how to make the declaration or how to use the date class as a member of the railcar class.. Can anyone help Me with this program? im really quite lost on how to start this.. Can anyone tell me how to use a class as a member of another class because im really having a hard time figuring out what to do.. I want to use the date class to get the date for the railcar class. what should I do? Can anyone help me out?? please please!! Thanks!!
Knightz101
|
|
|
|
|
Have you been to all your classes, and listened to the teacher and did all the required exercises and reading ?
Did you asked those questions to your teacher and/or teaching assistant ?
I don't want to sound harsh, but all this is pretty basic, and if it's an course assigment, you should do it yourself.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
class Date
{
//blah blah
};
You have now created a data type called Date. You can use it as you would any data type like int or char.
class RailCar
{
double capacity;
Date dateOfManufacture;
}
|
|
|
|
|
Hi,
I have a client that says he is having some problems with my application. I would like to know the state of the application when he has said problems. I will send him a debug version of the executable, and ask him to create a core dump of the program when he is having problems.
Now, my two questions:
1) What can I use on a Windows XP system that can create a program core dump?
2) What application do I use to view the core dump? (I have MSVC 7.1)
Thanks
- Andrei
|
|
|
|
|
1) Dr Watson (drwtsn32.exe, found in the system dir of every XP installation)
2) VS will work just fine - open the .dmp file, and hit Debug - the context dumped will be displayed.
There are also several relevant articles here, you'd do well to spend a bit of time reading up on it.a
|
|
|
|
|
Hi there,
Was wondering if anybody why i get this exception while sending data over a socket. I am using CAsyncSocket for socket connections. I am getting error code 0 when i catch the exception and call GetLastError(). I cant seem to be able to trace why this is happening as the error generates randomly. Any advice on how to handle this and i would really appreciate if somebody could help me out on this.
Thanks
|
|
|
|
|
What's the exception that's thrown?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
This is all that i am getting "The operation completed successfully"
|
|
|
|
|
is it realyl an exception or is something returning 0?
If its an exception, run it in the debugger and set the debugger to break on an exception. This will show you where its being thrown from and should give you some idea of whats going on.
Usually 0 means success. Are you sure its really broken?
|
|
|
|
|
Hi,
I have a MFC dialog that I want to be in a static library. When it is in the static library and I call DoModal on it, the FindResource comes back with 0.
<br />
if (m_lpszTemplateName != NULL)<br />
{<br />
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
hDialogTemplate = LoadResource(hInst, hResource);
}<br />
Is it possible to have a dialog defined in static library with MFC support? I should point out that made sure that all the resource identifiers are out of the range of all other identifiers in the program (ie, 5000+)
Sincerly,
Clint Singer
|
|
|
|
|
clintsinger wrote: Is it possible to have a dialog defined in static library with MFC support?
Yes. But since you can't link resource templates into static libraries, you'll need to remember to do so in the app that uses them. For instance:
- Clint.exe links with ClintLib.lib, and has resources specified in Clint.rc
- ClintLib.lib contains class for dialog, template for dialog is defined in ClintLib.rc
- Clint.rc must
#include ClintLib.rc in order for those resources to be available at runtime.
|
|
|
|
|
Thank you. It worked!
Cheers,
Clint
|
|
|
|
|
Hi,
I am trying to call SetWindowText on a CEdit control, but can't seem to
make a line break appear within the control.
m_MyEdit.SetWindowText( _T("Three \n Different \n Lines");
I want the output:
Three
Different
Lines
I am using the multiline style, and the read only style.
Thanks.
|
|
|
|
|
atom wrote: m_MyEdit.SetWindowText( _T("Three \n Different \n Lines");
Use:
_MyEdit.SetWindowText( _T("Three\r\nDifferent\r\nLines");
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi
You most Set Multi line & Want Return Properties of your Edit control
Iman Ghasrfakhri
|
|
|
|
|
Ghasrfakhri wrote: You most Set...Want Return Properties of your Edit control
Not required.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
First post, I usually can find what im looking for by searching but this seems to have eluded me.
I want to create a window that cannot be resized and its getting frustrating.
I have made up a solution that will work, but it looks messy.
What it does is use the CS_HREDRAW and CS_VREDRAW window styles to tell the window to redraw everytime its addjusted. Then in the case for recieving that message I calculate the difference between the top and bottom, and left and right sides. If they are not the size i want then it resets them to that size and redraws the window. As you can imagine when somenoe trys to resize the window it blinks rediculously untill they stop. Is there some other way of acchiving this? I still want the end user to be able to move it about the screen, just keeping the same size.
|
|
|
|
|
remove the WS_THICKFRAME style from your CWnd derived frame window ( I assume that is what you have )
or handle the WM_GETMINMAXINFO message to prevent the resizing of the window.
search for WS_THICKFRAME in msdn, there's an article there about that.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
thanks
I was using WS_OVERLAPPEDWINDOW wich inclused WS_THICKFRAME
I must have read over that 100 times and it just didnt click
hate it when that happens
|
|
|
|
|
Hello,
I have the following problem. I want to create a temporary object that is transparent to the caller of the function which creates the temporary. We all know that a temporary object is created on the stack for objects returned by value from a function.
I wan't to use this property of the temporary to create a locking / unlocking mechanism for an object. See the following code for details
class CArbitraryClass
{
public:
void DoFoo() {}
};
class CWrapperClass
{
public:
CInvisibleTemporary operator->()
{
return CInvisibleTemporary::CInvisibleTemporary();
}
};
class CInvisibleTemporary
{
public:
CArbitraryClass& operator->() { return m_ArbitraryObject; }
private:
CArbitraryClass m_ArbitraryObject;
};
So the code should look like the following statements:
CWrapperClass Wrapper;<br />
Wrapper->DoFoo();
But it looks like:
CWrapperClass Wrapper;<br />
Wrapper.operator ->().operator ->().DoFoo();
Am I trying to do something impossible?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|