Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

array inside class

$
0
0

Can I declare and allocate memory to an array in class as given below:

 
class hci_test
{
public:
unsigned char* host_hci_pkt_arr;

host_hci_pkt_arr = new(nothrow) unsigned char [2];
host_hci_pkt_arr[0] = 0x01;
host_hci_pkt_arr[1] = 0x02;     
};

While I am compiling above following errors are generated:

std::nothrow’ cannot appear in a constant-expression
hci_test.cpp:75: error: ‘new’ cannot appear in a constant-expression
hci_test.cpp:75: error: ISO C++ forbids declaration of ‘host_hci_pkt_arr’ with no type
hci_test.cpp:75: error: ISO C++ forbids initialization of member ‘host_hci_pkt_arr’
hci_test.cpp:75: error: making ‘host_hci_pkt_arr’ static
hci_test.cpp:75: error: ISO C++ forbids in-class initialization of non-const static member ‘host_hci_pkt_arr’
hci_test.cpp:75: error: declaration of ‘int hci_test::host_hci_pkt_arr’
hci_test.cpp:69: error: conflicts with previous declaration ‘unsigned char* hci_test::host_hci_pkt_arr’


Please tell me the solution.


Viewing all articles
Browse latest Browse all 595

Trending Articles