Why is VCPP Jacked up?

I don't get it. VCPP doesn't allow you to include standard preprocessor directives such as <iostream> or <fstream>. Instead if has stdafx.h or whatever. Why is it like this and what can i do to be able to use REAL C++ libraries?
If you create a project with the default settings, it enables precompiled headers, which puts everything in that stdafx.h

If don't want that, when you make a new project, be sure to check the "Empty Project" box. Then it works normally.
The inclusion of stdafx.h doesn't stop you from adding your own include files. It's just really annoying.
So you add the files to the project or somthing? I want to check this out before I download (a very unreasonably large) program. Right now, im exploring it at school.

VCPP have the advantage of an easier GUI creation interface, which is why I'm looking into it.
Last edited on
What files do you mean, the standard iostream, fstream, ... No, you don't add these to the project, you just include them in your source file(s).
I don't understand... how are you supposed to write C++ without the basic include files?
I don't understand... how are you supposed to write C++ without the basic include files?


Huh? You can always include the standard header files. Nobody is saying otherwise.

"stdafx.h" is just a precompiled header that VC++ throws in there. Precompiled headers can potentially speed up compile times, but I find they can often create problems/compiletime oddities so I avoid them unless compiling without them is REALLY slow.

If you don't want to use them, don't. When you make a project in VC++, simply check the "Make Empty Project" checkbox and VC++ will make a "normal" project without the stdafx.h crap.
ohhh. So Code::Blocks has precompiled headers?

Another question: Where can i find informational/instructional resources for creating a GUI program with VCPP?

Will <iostream> etc. work with GUI in VCPP?
#include <iostream> will be recognised by any C++03 compliant compilers, including Visual C++ versions 6.0, 7.0, 7.1, 8.0, 9.0 and 10.0.

Why don't you just use it? I can't believe you're still asking about this.
Last edited on
I figured it out, but i cant get the labels and buttons to interact. I need a resource. Can anyone point me to a website that i can use for reference?
What i would like to do is make a check book type of program. It will open a file, get the information and change a label accordingly, but the <iostream> library doesnt seem to be working with it...
I see. Why do you think it isn't working?
It is not that it is not working. It's more along the lines of consol vs win32. I want to make a graphic interface but i have no experience with makeing one. I have a lot of experience, though, with console programming.
here is a code sample:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#pragma endregion
	private: System::Void balance_Click(System::Object^  sender, System::EventArgs^  e) {
				 string line;
				 ifstream f;
				 f.open("bal.dat", ios::in);
				 if(!f.is_open())
				 {
					 line = "0.00";
					 balance = line;
				 }
				 getline(f, line);
				 balance = line;
			 }
	};
}


here are the errors i get when this is compiled with the rest of the VCPP stuff:

1
2
3
4
5
6
7
1>c:\users\username\desktop\gui c#\project_gui.h(99): error C2440: '=' : cannot convert from 'std::string' to 'System::Windows::Forms::Label ^'
1>          No user-defined-conversion operator available, or
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\username\desktop\gui c#\project_gui.h(102): error C2440: '=' : cannot convert from 'std::string' to 'System::Windows::Forms::Label ^'
1>          No user-defined-conversion operator available, or
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


also, i did have the basic preprocessor includes:

<iostream>, <fstream>, and <string> for this. So it is somthing else...
Last edited on
Those are syntax errors. It has nothing to do with header files. You really should stop blaming the tools.

I guess the errors are in:
 
    balance = line


I am not sure about this, but you may need this instead:
 
    balance.Text = line.c_str();
if you read my code, you would know that 'line' is declared as a string. Also, balance.Text is a syntactical error. It indicates a data structure. I think you are talking aboiut Basic and not C++.

and btw, im not blaming the "tools". I'm simply expressing my confusion with the way Visual C++ is.
Last edited on
Your code is C++/CLI, which (despite the name) is an entirely different language from C++.

I'm not sure if <iostream> will work with C++/CLI because it's a C++ header, not a C++/CLI header.
Try
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
private: System::Void balance_Click(System::Object^  sender, System::EventArgs^  e) {
				 string line;
				 ifstream f;
				 f.open("bal.dat", ios::in);
                                 String^ sysString;
				 if(!f.is_open())
				 {
					 line = "0.00";
                                         sysString = gcnew String(line.c_str());
					 balance->Text = sysString;
				 }
				 getline(f, line);
                                 sysString = gcnew String(line.c_str());
				 balance->Text = sysString;
			 }

@Disch From my very limited CLI experience std headers can be included and used.
Last edited on
Are there any references for C++/CLI? What is CLI?
Topic archived. No new replies allowed.