[help]coding In C++ Error

I am working on a visual c++ program... and all i have right now is a form with a lot of labels, text boxes, and buttons. I get the following error every time i try to compile:

c:\Documents and Settings\guest.CT6432\My Documents\Visual Studio Projects\HangmanProj\Form1.h(698): error C2440: '=' : cannot convert from 'System::String __gc *' to 'System::Windows::Forms::Label __gc *'

If you know how to fix this, i'll pay you any amount of nothing you want.

Its really important, so please help

EDIT: this is the line of code that the error is on:

this->Name = S"Form1";

#150539

Staff: This is what would go in a Developer section. Questions pertaining to programming.

@ Rooskee - I am sorry, I have little knowledge with C++ and even less with Visual C++. The only things I could tell you will probably be the obvious. Could you possibly give us the line that this error occours (Line 698)? That could probably help a little, although it is obvious what you are doing.

#150543

This looks Like C++.NET or C#.

The error basically says that you have a Label named 'Name' on your form and that you are assigning it a String 'Form1'.

My guess is that you want the Label to say 'Form1'. Try

this->Name.Caption = S"Form1";

BTW, What's the S in front of the string? Does it makes the string a shared string or....?

// waits for Stevie to drop by and explain

#150676

I haven't a clue what the S in front would do...

this->Name.Text might work, because .Net uses .Text, rather than .Caption...

Also, .Name is typically used for the unique identifier of an object, so this->Name should be the name of the current form (assuming C++.Net works the same way as all the other .Net languages)...

#150692

thanks guys, i'll try this as soon as i get to the computer with the project on it... we dont have visual studio on our computers, we have to go to the lab to use it. It sucks

edit: the old error is gone, but tnew ones have shown up... and our teacher didnt teach us anything... i hate coding

#150730

Wow, you get to learn C++ at your college? All we get are a couple of C courses and ten million junky, useless Java classes.

#150773

Originally posted by Draxis Wolfe@Apr 26 2004, 09:17 AM

Wow, you get to learn C++ at your college? All we get are a couple of C courses and ten million junky, useless Java classes.

C++ was the AP Computer Science class up until last year for High Schools in the US. I took it, but I was a senior, so you know where that leads.

Now the AP Computer Science class is Java, in my opinion, a bad move. C++ is much more useful. If they wanted an interactive language, they should have moved to C#, but that would have cost too much money. So they should have stayed with C++, me thinks.

#150775

Originally posted by wizard@Apr 26 2004, 03:21 PM

C++ was the AP Computer Science class up until last year for High Schools in the US. I took it, but I was a senior, so you know where that leads.

Now the AP Computer Science class is Java, in my opinion, a bad move. C++ is much more useful. If they wanted an interactive language, they should have moved to C#, but that would have cost too much money. So they should have stayed with C++, me thinks.

Agreed. I managed to teach myself the basics of C++. Pretty much everything that isn't the STL. We still get one C++ class, though. Operating Systems. But guh, I really hate Java. I find it contrived, bloated, and useless and I can see why it never became the industry standard it claimed it'd be.

#150779

Java is a much prettier language to if it comes to learning OOP. It forces you much more than C++ to think in objects and actions.

Another nice thing is that it is platform independent. I am currently working on a not-too-small Java-project in a group and someone is writting his classes on a Linux machine, another one is writing test-drivers on UNIX while I am working under Windows.

With Java's 1.5 support for generics ( ~ C++-templates) the language is a bit easier to work with (no more MyClass)vector.get(i)).someMethod() ).

I still like to see a better iterator idea in Java. I think the STL is better when it comes to support for iterators and functions that will use iterators. I just love to do

  std::vector<int>vect;
 std::copy(std::istream_iterator<int>(std::cin),
               std::istream_iterator<int>(),
               std::back_inserter(vect)
             );

  std::copy(vect.begin(),vect.end(),
                 std::ostream_iterator<int> (std::cout, ",")
             );

or something like

std::string GetExtension(const std::string& fname)
{
std::string::reverse_iterator dotPosition = std::find(fname.rbegin(),fname.rend(),'.');

std::string ext;

if(dotPosition != fname.rend() )
 std::reverse_copy(fname.rbegin(),dotPosition,std::insert_iterator<std::string>(ext,ext.begin()) );

return ext;
}

Just my thoughts :canadian:

#150843