如何使用对象数组重载构造函数

时间:2018-04-15 21:50:18

标签: c++ constructor new-operator dynamic-memory-allocation

#include "Stock.h"
#include <iostream>
#include <stdio.h>

int main() {
if (SDL_Init( SDL_INIT_EVERYTHING ) < 0){     //initalize SDL2
  std::cerr << "SDL FAILED TO INITALIZE" << std::endl;
  return 1;
}
std::cout << "::Stock Simualator::" << std::endl; //start menu
stk::Stock *sObj = new stk::Stock("Nasdq", 45.32)[100];
sObj[1].display();


SDL_Quit(); //End the program and clean EVERYTHING up
delete sObj;
int c = getchar();
return 0;
}

如何向构造函数提供信息并为100个库存对象分配内存?

0 个答案:

没有答案