Error: Incomplete type is not allowed?

This is a discussion on Error: Incomplete type is not allowed? within the C++ Programming forums, part of the General Programming Boards category; Code: #pragma once #include "product.h" class DataStore { public: unsigned int findPrice(int id, Product dataStore[], int size); void sortProductIDs(Product dataStore[], ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    22

    Wink Error: Incomplete type is not allowed?

    Code:
    #pragma once
    #include "product.h"
    
    
    class DataStore
    {
    
    
    public:
        unsigned int findPrice(int id, Product dataStore[], int size);
        void sortProductIDs(Product dataStore[], int size);
        void delete_id(Product dataStore[], int id, int size);
        void l_find_id_price(Product dataStore[], int * id, unsigned int * price, int size);
    
    
    private:
        static int const MAX = 5;
        DataStore theDataStore[MAX];
    };

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Did you mean to make theDataStore static? Because otherwise, every instance of DataStore wants to contain 5 more instances of DataStore, which isn't possible.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    I love to see C code with classes......wait a second, are you an apple programmer?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,013
    There was once an apple, which contained 5 other apples.
    Those other 5 apples, in turn, contained 5 more apples.
    Now, those 25 apples all contained another 5 apples each.
    And so on... yeah...

    Now, substitute "Apple" for "DataStore" and you've found your problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,646
    Unrelated to the original problem, but avoid using #pragma once. Better to use include guards in header files (same net effect, not compiler specific).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-23-2011, 03:04 PM
  2. error: array type has incomplete element type
    By gerger in forum C Programming
    Replies: 8
    Last Post: 10-05-2010, 08:40 AM
  3. Compile Error: Incomplete Type
    By estebbins in forum C Programming
    Replies: 2
    Last Post: 07-07-2008, 11:00 PM
  4. error: field has incomplete type
    By kris.c in forum C Programming
    Replies: 11
    Last Post: 06-12-2007, 04:53 PM
  5. "error: incomplete type is not allowed"
    By Fahrenheit in forum C++ Programming
    Replies: 9
    Last Post: 05-10-2005, 10:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21