Category : pointers

I was studying pointers in arithmetic today, and I got stuck at a point where I didn’t understand a thing. I initialized an integer variable with "10" as its value inside it. I declared another pointer variable (*p) in which I stored the address of "a" and then I added 3 to it. According to ..

Read more

I checked the size of an int pointer as follows: #include <iostream> using namespace std; int main() { int temp [10]; int *ptr=&temp[0]; cout<<sizeof(ptr)<<endl; } This should give output as 8 according to my knowledge but it gives 4. Source: Windows Que..

Read more

I was trying to run a OnnxRuntime Inference on a image file of jpg format using a pretrained Squeezenet model as illustrated in the blog: https://leimao.github.io/blog/ONNX-Runtime-CPP-Inference/ using the script in the link: https://github.com/leimao/ONNX-Runtime-Inference/blob/main/src/inference.cpp . It did work: Now I had a requirement to replace the the input file format from jpg to raw, but upon ..

Read more

I have a function as follows int check_inband_status(Port **ePort, Port **wPort, InbandPort *inbandPort) { std::ifstream ring_config_file(RING_CONFIG_FILE); Json::Value ring_config; ring_config_file >> ring_config; (*ePort)->port_id = ring_config["east_port"]["port_id"].asInt(); (*ePort)->port_type = ring_config["east_port"]["port_type"].asString(); (*wPort)->port_id = ring_config["west_port"]["port_id"].asInt(); (*ePort)->port_type = ring_config["west_port"]["port_type"].asString(); ring_config_file.close(); } I have a json file and I am reading it and assigning the values to ePort and wPort. This is ..

Read more

So guys I’m trying to learn Polymorphism in C++ and the way I’ve been learning it was with raw pointers or smart pointers but then I’ve been trying to use regular pointers this time and I even tried to add the pointers to a vector from the constructor like this: std::vector<bank_account*> bank_accounts; bank_account::bank_account(std::string Name, int ..

Read more