Error: Expected primary-expression before '==' token

I Keep Getting The Error. Error: Expected primary-expression before '==' token.
Can somone help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include "placeName.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <ctime>
using namespace std;

class RandonRegionName{
    public:

    int P_Name(){
    srand(static_cast<unsigned int>(time(0)));
    int placeName = rand();

    return (placeName % 3) + 1;
}

    void randomPlaceName(){
        string RegionName;
       if (placeName == 1)
        {
        RegionName = "Pandonia";
        }
       else if (placeName == 2)
       {
         RegionName = "Shires";
       }
       else if (placeName == 3)
       {
          RegionName = "Epic";
       }

    }};
The variable placeName is not recognized by the function randomPlaceName(). It is delared as a local variable in the function P_Name().
Ok. How do i get it to be recognized?
Possibly like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class RandonRegionName{
   private:
      int placeName;
    public:

    int P_Name(){
    srand(static_cast<unsigned int>(time(0)));
    placeName = rand();

    return (placeName % 3) + 1;
}

    void randomPlaceName(){
        string RegionName;
       if (placeName == 1)
        {
        RegionName = "Pandonia";
        }
       else if (placeName == 2)
       {
         RegionName = "Shires";
       }
       else if (placeName == 3)
       {
          RegionName = "Epic";
       }

    }};
Topic archived. No new replies allowed.