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

  • SEARCH
  • Home
  • 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 6681561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:36:15+00:00 2026-05-26T04:36:15+00:00

I am new to C++ so please bear with me. Basically, I am creating

  • 0

I am new to C++ so please bear with me.

Basically, I am creating the Header for one of my Classes, and have come into a spot of difficulty.

An instance of the Class in question is created by the Main() function, now when this instance of the Class is created I want to pass in the Array length. However, I cannot do this if it is declared statically in the Header, right?

Any solutions? Sorry, this is probably very simple, but I am coming from a Java background, I’m trying to not do things the Java way.

Thanks.

  • 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-26T04:36:15+00:00Added an answer on May 26, 2026 at 4:36 am

    If you are programming in C++ and are looking to declare an array of variable size, then odds are you don’t want to use a “built-in” C style “array”. It’s sort of a nuts-and-bolts tool.

    You probably want to use std::vector instead. It is a class which is more flexible and does not require a size to be specified at the point of declaration. You can look for tutorials on its use around the web, but here’s a random one from Google:

    http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html#VECTOR

    An interesting aspect of C++ is that even though vectors are “library code” and a class you could have potentially written yourself without modifying the compiler, they allow for access with notational conveniences like brackets. Some pros from the faq and some cons from the fqa presented here, take both sides with a grain of salt:

    http://yosefk.com/c++fqa/operator.html

    While there are some performance benefits to using the bare metal abstraction of a C-style array, std::vector is almost certainly faster than Java arrays and are a better choice much of the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to WPF, so please bear with me. Basically I have defined
I am new to Ruby and Rails so bear with me please. I have
I'm quite new to Node.js, so please bear with me... Bascially, I have a
I am new to iOS development so please bear with me. I have created
I am new to Jrockit mission control so please bear with me. I have
Please bear with me, I come from .net and am new to the java
I am new to Javascript so please bear with me. I have a Javascript
I am new to WPF/XAML so please bear with the noob question. I have
First time poster so please bear with me. Basically I have a pdf document
I am relatively new to Delphi so please bear with me. Basically, I need

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.