0

was watching this c++ tutorial on youtube :https://www.youtube.com/watch?v=Rub-JsjMhWY (part i'm referring to starts around 20mins in). Was following the video and was wondering why i was getting this error:

error: 'stod' was not declared in this scope.
Wondering why I'm getting this error here is my code thanks.

#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>

using namespace std;
int main(){
    string yourName;
    cout << "whats your name? ";
    getline(cin, yourName);
    cout<< "hello "<<yourName<<endl;
    double numberConstant = 0.57721;
    string numberguess;
    double numberguessDouble;
    cout<< "Guess a number between 1 and 10";
    numberguessDouble = stod(numberguess);
    if (numberguessDouble == numberConstant){
        cout << "You guessed the correct number of " << numberConstant <<endl;
    }
    else
    {
        cout<< numberguessDouble << " is incorrect the number was "<< numberConstant<<endl;

    }
}
juanchopanza
  • 223,364
  • 34
  • 402
  • 480
  • [`std::stod()` is defined in ``.](http://en.cppreference.com/w/cpp/string/basic_string/stof) Which you're including. So it's more likely a setup problem: versions, compiler. For which you'd need to provide more detail. PS: it'd make things easier for everybody if you could reduce your code block's size to the minimum that exposes the error. – JB. Sep 29 '15 at 06:15
  • Why dupilcate, link refers to stoi() and not to stod()! – user1 Sep 29 '15 at 06:17
  • @user1 It is really the same problem, and it has the same answer. – juanchopanza Sep 29 '15 at 06:21

0 Answers0