Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 951581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:45:29+00:00 2026-05-15T23:45:29+00:00

here is implementation IntSetList in c++ #include <iostream> using namespace std; class IntSetList{ private:

  • 0

here is implementation IntSetList in c++

#include <iostream>
using namespace std;

class IntSetList{

private:
    int n;
    struct node{

        int val;
        node *next;
        node(int v,node *p){val=v;next=p;}
    };
    node *head,*sentinel;
    node *rinsert(node *p,int t){

        if (p->val<t){
            p->next=rinsert(p->next,t);


    }
        else   if (p->val>t){
            p=new node(t,p);
            n++;
        }
         return p;
            }



public:
    IntSetList(int maxelens,int maxval){
        sentinel=head=new node(maxval,0);
        n=0;
            }



    int size() { return n;}

    void insert(int t){  head=rinsert(head,t);}
    void report(int *v){

         int j=0;
         for (node *p=head;p!=sentinel;p=p->next)
             v[j++]=p->val;



    }




    void display (int *v){
         for (int i=0;i<sizeof(v)/sizeof(v[0]);i++){
             cout<<v[i];
         }





    }

};

int main(){



    IntSetList s(10,15);
    int v[10];
    s.insert(7);
    s.insert(2);
    s.insert(1);
    s.insert(11);
    s.insert(13);
    s.insert(14);
    s.insert(5);
    s.insert(6);
    s.insert(12);
    s.insert(9);
    s.report(v);

    s.display(v);






     return 0;
}

but it does not show me any output of course there is c++ standart library but i need to implement myself so i am making practises please help what is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:45:30+00:00Added an answer on May 15, 2026 at 11:45 pm

    No output at all? I suspect that it is outputting at least one number, since sizeof(v) is at least as big as sizeof(v[0]), but probably only just as big, since a pointer is the same size as an int on most 32-bit computers.

    The sizeof(v)/sizeof(v[0]) trick only work on arrays, not pointers. A common trick to get around this is to declare the function as a template, thus:

    template <int N>
    void display (int (&v)[N])
    {
         for (int i = 0; i < N; ++i)
         {
             cout << v[i];
         }
    }
    

    A more conventional solution is to pass the length explicitly:

    void display (int *v, int n)
    {
         for (int i = 0; i < n; ++i)
         {
             cout << v[i];
         }
    }
    

    A couple of points to note:

    1. This will mash all the numbers together because you haven’t put any whitespace in between them.
    2. The display function doesn’t have to be a member of IntSetList, since it doesn’t interact with the class at all.

    The simplest solution, BTW, is to not write the function at all:

    std::copy(v, v + sizeof(v)/sizeof(v[0]), std::ostream_iterator<int>(std::cout));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is my code for xor linked list implementation #include<iostream> using namespace std; struct
Here is my implementation in summary 1) all DAOs implemented using HibernateDAO support/ @Transational
Here is the hashCode() implementation from Java HashTable Class. What if the number of
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
Here is my perceptron implementation in ANSI C: #include <stdio.h> #include <stdlib.h> #include <math.h>
Here is a very basic class for handling sessions on App Engine: Lightweight implementation
Here's a question that comes up again and again in C++ class implementation. I'm
Given: interface ViewableDTO {//methods here} class PersonDTO implements ViewableDTO {//implementation here} This works fine:
Here's the implementation of java.lang.reflect.Method.equals(Object obj) as of Java 7: /** * Compares this
I'm having some difficulties getting the TabActivity to work. Here's the implementation of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.