Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C++ Application Development with Code::Blocks

You're reading from   C++ Application Development with Code::Blocks Using Code::Blocks it's possible for C++ developers to create application consistency across multiple platforms. This book takes you through the process from installation to implementing advanced features, all with a user-friendly approach.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher
ISBN-13 9781783283415
Length 128 pages
Edition Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
BIPLAB MODAK BIPLAB MODAK
Author Profile Icon BIPLAB MODAK
BIPLAB MODAK
Arrow right icon
View More author details
Toc

Project with multiple files


In this section we'll learn about C++ app development comprising of multiple files. We'll develop a class, called Vector, which implements a dynamic array. This class is similar to the std::vector class offered by Standard Template Library (STL) and has a very limited set of features compared to STL class.

Create a new project and name it App2. Navigate to File | New | File… menu option and then choose C/C++ header option and follow the wizard to add a new file to App2 project. Add the following code in a new file under App2 and name it vector.h file:

#ifndef __VECTOR_H__
#define __VECTOR_H__

#ifndef DATA_TYPE
#define DATA_TYPE double
#endif

class Vector {
public:
    Vector(size_t size = 2);
    virtual ~Vector();

    size_t GetCount() const;

    bool Set(size_t id, DATA_TYPE data);
    DATA_TYPE operator[] (size_t id);

private:
    DATA_TYPE* m_data;
    size_t     m_size;
};

#endif //__VECTOR_H__

Header file vector.h declares the Vector class structure....

You have been reading a chapter from
C++ Application Development with Code::Blocks
Published in: Oct 2013
Publisher:
ISBN-13: 9781783283415
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image