Need advice

Hello to everyone, I'm a new member and need help with my code.
Write a constructor that initializes a new inventory object with the values passé as arguments, but which also includes a reasonable default value for each parameter.

#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
#include <string.h>
class inventory
{
private:
int prodID;
char prodDescription[20];
int qtyInStock;
public:
inventory()//default constructor
{
prodID=0;
strcpy(prodDescription,"-");
qtyInStock=0;
}
inventory(int a,char *b,int c) //constructor that initializes a new Inventoryobjects with the values passed as arguments
{
prodID=a;
strcpy(prodDescription,b);
qtyInStock=c;
}
};
int main(int argc, char* argv[])
{
inventory obj(1,"cotton tshirt",4);
return 0;
}
Please Im not trying to get my homewotk done, just to understand my errors.
It complies without problem. But doesn't run.
Thanks again
Last edited on
> But doesn't run.
It does run. Your program does not take input and does not produce output, it simply creates an object and never use it.

> It complies without problem
It shouldn't.
the correct header is just iostream
Last edited on
Hi and thanks, the cout statement should go before the main() right?
Topic archived. No new replies allowed.