including a function from a header

Jun 7, 2013 at 9:16pm
How do you include just one function from a header. Specifically, I want ceil, floor and pow from <cmath>. The is a function being used by it that has the same name as my class
Last edited on Jun 7, 2013 at 10:08pm
Jun 7, 2013 at 9:29pm
You always include all the functions.
To get around that, in your program don't use using namespace std;. You will need to use std::ceil(x) and so on, for all functions and variables in the std namespace. So instead of
1
2
3
4
5
6
7
8
#include<iostream>

using namespace std;

int main()
{
   cout<<"Hello world"<<endl;
}


you will have

1
2
3
4
5
6
#include<iostream>

int main()
{
   std::cout<<"Hello world"<<std::endl;
}


Jun 7, 2013 at 10:09pm
Im not asking about std; Im asking about cmath
Jun 7, 2013 at 10:15pm
1) Wrap your class in a namespace
2) Investigate the function/class in the library to see if you can use that instead of your class
3) Consider renaming your class
Topic archived. No new replies allowed.