You should not #include source files.
Given that your *.cpp contains a class definition, it may be more adequate as an *.h, that can be included. It would need header guards
You have #define test testcase_001; //parameter
Macros are simply text substitution, so you'll have
1 2 3 4 5 6
class hci_test
{
public:
unsignedchar* host_hci_pkt_arr;
unsignedint address;
testcase_001; test_case;//note the semicolon
> if what you mean is "if you can declare objects that way" well, the answer is YES ( but it is not advisable )
¿why not?
¿what would be the "proper" way?
what i mean is #defines are less advisable compared to other alternative ( like typedef or const )
but in the above case it doesn't really matter since he just define an alias for a type
I want to pass parameter like i had passed tescase_001 in first line of code likewise this i want to pass testcase_002, 003, 004, and then I want that corresponding file automatically included as done in 2nd line and respective object also created. But I think following is not right way as compiler showing error: cannot find test.cpp.
And I think its all because of first line, may be its not the right way to pass parameter in C++, Actually I am developing some block in systemC. but systemC is inheriting all features, syntax of C++. Thats why I am asking this question here
#define test testcase_001; //parameter
#include "testcases/test.cpp" //could i pass parametrised value here?
class hci_test
{
public:
unsigned char* host_hci_pkt_arr;
unsigned int address; test test_case; //object
hci_test() //constructor
{
host_hci_pkt_arr = new(nothrow) unsigned char [20];
host_hci_pkt_arr[0] = test_case.host_hci_pkt_arr[0];
host_hci_pkt_arr[1] = test_case.host_hci_pkt_arr[1];
}
};
Wait, are you saying you want to do something like
1 2
#define test testcase_001
#include "testcases/test.cpp"
and have the test.cpp become testcase_001.cpp by macro substitution?
I don't think it's possible at all, but maybe someone with a more thorough understanding of the preprocessor can step in....
The best I have to offer is
1 2 3 4 5 6
#ifdef testcase_001
#include "testcases/testcase_001.cpp" // By the way, why are you #including .cpp files?
#elif defined testcase_002
#include "testcases/testcase_002.cpp"
// ... so on and so forth
#endif