c++ programming realted , array of numbers


I’m new to c++ .This is the first part of my program.I want the output of list a .But it doesn’t give a output.only get input.After getting inputs the program stops.

#include <iostream>
using namespace std;

class clist {
 int i, j,k,times;
 double numbers[1000];
 clist () {

 clist(int j) {
     k = j;
     cout << "Enter the numbers" << endl;
     for (times = 0; times < k; times++) {
         cin >> numbers[times];
 void print_lista() {
     for (times = 0; times < k; times++) {
         cout << numbers[times] << "t" << endl;

int main()
 cout << "Enter how many numbers you want to enter" << endl;
 clist obj;
 cin >> obj.i; 
 clist obj2(obj.i);
 clist obj3;
 return 0;

Asked By: chami



your calling the print list function on obj3 which is empty.
remove obj3, call the function on obj2 and it will work.

it’s very sloppy code, I suggest you get a better understanding of c++ before you continue oop.

Answered By: Myth
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.