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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:41:54+00:00 2026-06-09T10:41:54+00:00

I have many classes in the system that I’m currently developing and in these

  • 0

I have many classes in the system that I’m currently developing and in these classes I have an array about the “name” of something. The name should be at most 30 characters.

Initially I used just 10 characters but now I need to increase the limit. Increasing the limit takes time though because I use this kind of array in many places. It would be easier if I used #define NAME_SIZE 30 or something like that and then all I would have to do is change one number instead of around twenty.

However I’m not sure if that’s a “legal” thing to do in C++.

It would save me tons of time in the future, that’s why I’m asking.

  • 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-06-09T10:41:55+00:00Added an answer on June 9, 2026 at 10:41 am

    Yes, there is nothing technically wrong with it, except that #define is usually inferior to a const std::size_t MAX_NAME_SIZE = 30; Even better would be to have a dynamic size, e.g. using std::string.

    Scott Meyers has an interesting column about systems that use gratuitous fixed sizes, called The Keyhole Problem

    The Keyhole Problem arises every time software artificially restricts
    something you want to see or something you want to express. If you
    want to see an image, but your image-viewing software artificially
    restricts how much of that image you can see at a time, that’s the
    keyhole problem. If you want to specify a password of a particular
    length, but your software says it’s too long, that’s the keyhole
    problem. If you want to type in your U.S. telephone number, but your
    software refuses to let you punctuate it in the conventional manner
    with a dash between the three-digit prefix and the four-digit
    exchange, that’s the keyhole problem.

    Apart from annoynance from users, you also open your systems to all sorts of security issues (e.g. buffer overflow exploits).

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

Sidebar

Related Questions

I have an ASP.NET project that contains many classes. I am thinking about creating
I have a (C++) system that has many classes that have variable storage (memory)
I have two C# classes that have many of the same properties (by name
Ok so I'm doing a simulation about a Mall I have many classes in
I have many structs (classes) and standalone functions that I like to compile separately
I have a abstract base class that I have many inherited classes coming off
We have many questions here about stack traces and analyzing exceptions that have been
So .... There are obviously many questions that all have been asked about Singletons,
In a system I'm currently working on, I have many components which are defined
I'm working on a large project (for me) which will have many classes and

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.