Hi, I would have replied in the last thread instead of creating a new one again but I have a dial up connection and dad doesn't like me tying up the phone lines at this time in the year. In the last thread I asked how to find the cubed root of a variable and Narue gave me this segment of code (thanks for your help btw)

#include <cstdlib>
#include <cmath>
#include <iostream>

int main()
{
  int val;

  std::cout<<"Enter a number: ";
  
  if ( std::cin>> val ) 
  {
	  std::cout<<"Cube root of "<< val <<": "
		  << std::pow ( std::abs ( val ), 1.0 / 3.0 ) <<std::endl;
  }
  return 0;
}

I tried compiling it and got two errors saying that pow and abs were not members of std, what should I use instead?

C:\Program Files\Microsoft Visual Studio\VC98\cube.cpp(14) : error C2039: 'pow' : is not a member of 'std'
C:\Program Files\Microsoft Visual Studio\VC98\cube.cpp(14) : error C2039: 'abs' : is not a member of 'std'
Error executing cl.exe.

>but I have a dial up connection and dad doesn't like me tying up the phone lines
What the hell are you talking about? It's no faster to create a new thread than it is to reply to an existing one. That's a lame excuse for being lazy.

>what should I use instead?
A better compiler. You're probably using some crappy compiler like Visual C++ 6. The code can be dumbed down for older compilers easily:

#include <stdlib.h>
#include <math.h>
#include <iostream>

int main()
{
  int val;

  std::cout<<"Enter a number: ";
  
  if ( std::cin>> val ) 
  {
	  std::cout<<"Cube root of "<< val <<": "
		  << pow ( abs ( val ), 1.0 / 3.0 ) <<std::endl;
  }

  return 0;
}

Though I guess I shouldn't have expected you to bother trying to remove std:: from pow and abs before running here to cry about the code you were so kindly given not working.

Though I guess I shouldn't have expected you to bother trying to remove std:: from pow and abs before running here to cry about the code you were so kindly given not working.

actually I did and I got the same results, as for the dialup thing I disconnected and tried your code as well as a few other theories and someone was on the phone when I wanted to post again. I think I may have it figured out though, thanks for your help and I'm sorry to have been such an annoyance

Edited 3 Years Ago by Dani: Formatting fixed

This article has been dead for over six months. Start a new discussion instead.