Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

C++ vs Visual C++ .NEt

I built a C++ console application program using Borland C++ 5.

I recently purchased Visual Studio C++.NET and wanted to make a few changed to this application. IT's a compare program, nothing complex, so i created a new project and copied the main.cpp file contents into the new Visual C++.Net file.

I built the program but it does not compile. It had many errors. but all the errors were....
----------

binary 'operator' : 'type' does not define this

--------

what the lines consist of are

outfile<<name<<" "<<name2<<endl;

it can not read the << for some reason.

I'm not sure why this is, if there is something in the Visual C++.NEt environment that prevents me from compiling or what not.

Because this program works and runs and I use when i compiled and built it with Borland C++ 5.

Thanks for your time,
Pete "
0
pjam062402
Asked:
pjam062402
  • 6
  • 4
  • 3
  • +3
1 Solution
 
jhanceCommented:
What is "outfile"?  My guess is that it's a Borland-ism or you're left out an important #include.

Show MORE code.
0
 
AxterCommented:
Please post more of your code.

What type is outfile?
0
 
AxterCommented:
You beat me to it jhance.....

pjam,
Also, what type is name and name2?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jhanceCommented:
I guess great minds think alike....  Or is that simple minds....  No matter.  ;-)
0
 
pjam062402Author Commented:
oh sorry, didn't want to post too much code to clobber people with info,


outfile is just derived from

ifstream(infile1);
ifstream(infile2);
ofstream(outfile1);
ofstream(outfile2);

i tried it  

ofstream outfile1;

and

ofstream(outfile1);

same results.

and NAME is just a variable that i wanted to post to the outfile.

but i keep getting

Compiler Error C2679       and C2678


It always compiled and ran with Borland C++, in fact I currently use the program, but i just wanted to make a few changes to the program and recently purchased the Visual C++.Net and will be using this software from now on.
0
 
jhanceCommented:
Do you have:

#include <fstream.h>

In your file?
0
 
AxterCommented:
ofstream(outfile1);//Will not work

It should be "ofstream outfile1".

You should be using #include <fstream> and if you don't have using namespace std, you need to prefix std:: to your STL types.
Example:
#include <fstream>
std::ofstream outfile1;

If you're using fstream.h, then this could be your problem, because this file header is not part of the standard, and therefore, it can be different from one compiler to the next.
0
 
pjam062402Author Commented:
I included <fstream>  and changed it to <fstream.h>

I used std::fstream outfile1       and

fstream outfile 1.


this is the new error I get  for and so on

std::ifstream infile1;


Compiler Error C2079
'identifier' uses undefined class/struct/union 'name'

The specified identifier is an undefined class, structure, or union.

Possible cause

Initializing an anonymous union.
0
 
pjam062402Author Commented:
I included <fstream>  and changed it to <fstream.h>

I used std::fstream outfile1       and

fstream outfile 1.


this is the new error I get  for and so on

std::ifstream infile1;


Compiler Error C2079
'identifier' uses undefined class/struct/union 'name'

The specified identifier is an undefined class, structure, or union.

Possible cause

Initializing an anonymous union.
0
 
jhanceCommented:
It not clear to me what you are doing or even trying to do.

How about:

#include <fstream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
     ofstream outfile1;
     ifstream infile1;

     return 0;
}
0
 
pjam062402Author Commented:
int _tmain(int argc, _TCHAR* argv[])

if i'm not mistaken this is managed C++,  I'm not building a managed C++ application.  



I am just trying to get my program to work.   I won't post the code here because it's over 1000 lines of code.   It's basically a program that compares two files.  One old and one new.  BUt there are many files to be compared and according to what menu choice you pick, you will compare the two files you need compared.

However the problem is in regards to that this application compiled and was built using Borland C++ 5.0.  It ran successful and I currently use the application.

I just wanted to make a few changes to the code, but  I no longer use Borland C++ 5.0   I use Visual C++.NET and i built the program and i recieved these errors. Which I did no before using borland C++ 5.0


the error I received this time

Compiler Error C2079
'identifier' uses undefined class/struct/union 'name'

The specified identifier is an undefined class, structure, or union.

Possible cause

Initializing an anonymous union.
0
 
jhanceCommented:
You're mistaken, this is a standard C++ console application in Visual Studio .NET.

I tried to show you an example of what is needed to get an ifstream and an ofstream.

I don't want to see your 1000 lines of code as your error is simple.  But what you've posted here is inconsistent.

You mix "metaphors" for no obvious reason:

std::fstream outfile1
fstream outfile 1


You are typing syntax errors:

fstream outfile 1.


So this makes it VERY VERY unclear what you are doing and what is wrong.
0
 
jhanceCommented:
Here, I fixed the example so that you aren't confused:

#include <fstream>

using namespace std;

int main(int argc, char* argv[])
{
     ofstream outfile1;
     ifstream infile1;

     return 0;
}

PLEASE TRY TO COMPILE ONLY THIS CODE.  I'm TELLING YOU THIS WORKS:

---------------------- Done ----------------------

    Build: 1 succeeded, 0 failed, 0 skipped
0
 
DanRollinsCommented:
You are misspelling the name of your variable.  It is not
    name
it is something else.  Perhaps
    NAME
or maybe
    Name
or even
     nAmE

But I don't know for sure.  I called the psychic hotline and even they waffled around a bit.  And they charged me $17.34 even though the first two minutes were free.  I was able to chat with Elvis for a while, so you don't owe me anything.

-- Dan
0
 
griesshCommented:
Dear pjam

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jhance"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
MindphaserCommented:
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 4
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now