Thread: What are the implications of declaring data types but never using them?

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    What are the implications of declaring data types but never using them?

    What are the possible problems if I declare a bunch of data types and never use them? Do they take up a lot of memory? Will they slow run time? If it is an array do I have to delete it at the end of the program? What if the array is defined inside a class and never used? Do I still have to delete it?

    i.e.

    Code:
    class declarearrays{
    public:
    double **darray;
    double **darray2;
    void function1();//function that initializes darray
    void function2();//function that initializes darray2 with different parameters, may not be used.
    };

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Do they take up a lot of memory?
    Well the whole library will be linked/loaded, so either you get a bigger executable or the whole library code is loaded into RAM later when it's used by the program.

    Will they slow run time?
    No. You cannot expect the computer to spend time on something you don't use.

    Do I still have to delete it?
    No. It's very common to need only part of a library and link/load all of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what are the implications of volatile....
    By sanddune008 in forum C Programming
    Replies: 6
    Last Post: 06-29-2010, 04:33 AM
  2. declaring data type
    By sarathius in forum C Programming
    Replies: 4
    Last Post: 04-17-2008, 04:54 AM
  3. data types types...
    By gftmc in forum C++ Programming
    Replies: 3
    Last Post: 09-11-2006, 11:30 AM
  4. declaring function pointer types for callbacks
    By Pea in forum C Programming
    Replies: 6
    Last Post: 01-06-2005, 09:46 PM
  5. Declaring Pointers/Passing Data
    By Ryan_P in forum C++ Programming
    Replies: 10
    Last Post: 12-18-2002, 02:49 PM