tags:

views:

45

answers:

2

I have following code

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string d="georgia is nice country":
  string::iterator my;
  for (my=d.begin();my!=d.end();my++) {
    cout<<*my<<endl;
  }
  return 0;
}

but it causes a compiler error saying "my is undefined". What is wrong?

+1  A: 
string d="georgia is nice country"; // <-- semicolon, not colon
Praetorian
I thought for a moment there you were saying georgia is not a nice country.
Borealid
no georgia is very nice country
just here is a little poor live bit everything will be ok soon
Haha, edited the answer; this should avoid misconceptions.
Praetorian
+1  A: 

You need to put a semicolon instead of a colon after the string.

string d="georgia is nice country"; // <-- semicolon!
In silico