To access class methods without creating its object.

Hi,

Dear all

Normally when we want to call method of any other class we need to create its object then we can access its methods.

But i want to use my class as a header file and like other math like utilities i want use simple its function like sqrt(); or other.

Header file of class IndepTest .h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

#ifndef _INDEPTEST_H
#define _INDEPTEST_H

#include <boost/math/distributions/chi_squared.hpp>

using namespace std;
using namespace boost;

class IndepTest
{
Public:

void chi2test(......);

};


source file for IndepTest .cpp
1
2
3
4
5
6
7
8
9


void IndepTest:: chi2test()
{
...
....
}



now in my application i want to use it like other math functions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14

#include"indepTest.h"

..
..
void main()
{

....
chi2test(...);
...
..
}



thanks in advance
Last edited on
You can declare your functions as static. But actually sounds like you need your own namespace, rather than to use a class.
Thanks for your reply please can you give me an example how i can use it using namespace.

thanks again
Don't use
 
using a_name_space namespace

in header file
Here is the article on this site about namespaces. It has the examples you want and also other information that could be useful.

http://www.cplusplus.com/doc/tutorial/namespaces/
Topic archived. No new replies allowed.