including a function from a header

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
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;
}


Im not asking about std; Im asking about cmath
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.