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 6367349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:32:13+00:00 2026-05-25T00:32:13+00:00

struct G{ G&operator()(const int**a) { v<<a; std::copy(v.begin(),v.end(),std::ostream_iterator<int>(std::cout, )); return *this; } friend std::vector<int>&operator<<(std::vector<int>&v,const int**

  • 0
struct G{

    G&operator()(const int**a)
    {
       v<<a;
       std::copy(v.begin(),v.end(),std::ostream_iterator<int>(std::cout, " "));
       return *this;
    }
    friend std::vector<int>&operator<<(std::vector<int>&v,const int** n);
    std::vector<int>v;
};

std::vector<int>&operator<<(std::vector<int>&v,const int** n)
{
    v.insert(v.begin(),*n,*n+sizeof(*n)/sizeof(*n[0]));
    return v;
}

/// use it
G g; 
int v[8]={1,2,3,4,5,6,5,4};
g(&v);

I have two questions,
1. The above code returns with error cannot convert parameter 1 from 'int (*)[8]' to 'const int **'
2. I would like to pass in g as g({1,2,3,4,5,6,5,4}) instead of g(&v). But I don’t know how to do that and always wonder if g will accept it.
Thank you.

  • 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-25T00:32:14+00:00Added an answer on May 25, 2026 at 12:32 am
    1. &v is giving you the address of the array, when you want the address of a pointer. Try doing const int* x = v then g(&x).
    2. In C++0x, you can do this:

      G& operator()(std::initializer_list<const int>);
      g({1,2,3,4,5,6,5,4});
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code: struct Calc { Calc(const Arg1 & arg1, const Arg2 &
struct Div { int i; int j; }; class A { public: A(); Div&
I have some null struct, for example: struct null_type { null_type& someNonVirtualMethod() { return
I have some function to find a value: struct FindPredicate { FindPredicate(const SomeType& t)
Suppose I have the following two data structures: std::vector<int> all_items; std::set<int> bad_items; The all_items
struct A { std::string get_string(); }; struct B { int value; }; typedef boost::variant<A,B>
The following code: #include <vector> #include <algorithm> struct myStructDim { int nId; int dwHeight;
Given the following: struct Foo { int bar() const; }; struct IsEqual : public
Given the following: struct Foo { int bar() const; }; struct IsEqual : public
I wonder if I understood emplace_back correctly #include <vector> using namespace std; struct Hero

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.