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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:45:15+00:00 2026-06-12T03:45:15+00:00

I have a class named Model and in ypur .h file I have this:

  • 0

I have a class named Model and in ypur .h file I have this:

private:
    vector<int> memory(MEMORY_SIZE);

MEMORY_SIZE is a const in a define header with value 10.

when I try compile I’m gettind this error code

Model.h:33: error: ISO C++ forbids declaration of 'vector' with no type
Model.h:33: error: expected ';' before '<' token

I don’t know why this, I’m declaring the type of vector…


The complete header code:

/*
 * Model.h
 *
 *  Created on: Sep 13, 2012
 *      Author: ademar
 */


#ifndef MODEL_H_
#define MODEL_H_

#include "Config.h"
#include "Arduino.h"
#include <vector>

class Model {

    public:
        Model(int pin, char command[]);
        Model(int pin, int initialState, char command[]);
        bool isChanged(int currentState);
        char* getCommand(void);
        int getState();
        void setRange(int range);
        void usesMemory();

    private:
        int pin;
        int state;
        int range;
        long time;
        char* command;
        void updateTime();
        bool useMemory;
        std::vector<int> memory;
};

#endif /* MODEL_H_ */

And the C++ code:

/*
 * Model.cpp
 *
 *  Created on: Sep 13, 2012
 *      Author: ademar
 */

#include "Model.h"

Model::Model(int pin, char command[]) {
    *this = Model(pin,0,command);
}

Model::Model(int pin, int initialState, char command[]) {
    this->pin = pin;
    this->state = initialState;
    this->command = command;
    this->range = 1;
    this->useMemory = false;
    this->updateTime();
}

void Model::usesMemory(){
    this->useMemory = true;
}

void Model::setRange(int range){
    this->range = range;
}

bool Model::isChanged(int currentState) {
    if ((currentState >= (this->state + this->range) || currentState <= (this->state - this->range)) && ((this->time+WAIT_CHANGE)<millis())){
        this->state = currentState;
        updateTime();
        return true;
    }
    return false;
}

char* Model::getCommand(){
    return this->command;
}

int Model::getState(){
    return this->state;
}

void Model::updateTime(){
    this->time = millis();
}

And the error:

In file included from Honda.h:11,
             from Honda.cpp:8:
Model.h:33: error: ISO C++ forbids declaration of 'vector' with no type
Model.h:33: error: invalid use of '::'
Model.h:33: error: expected ';' before '<' token
  • 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-12T03:45:16+00:00Added an answer on June 12, 2026 at 3:45 am

    These are my shots that vector is not included or you are missing namespace std::. The compiler explicitly points out that it does not know what vector is.

    What is more, you don’t initialize fields like this in C++. You have to do it in the constructor:

    #include <vector>
    #include <iostream>
    
    #define MEMORY_SIZE 10
    
    class Clazz {
        std::vector<int> memory;
    
        public:
            Clazz() : memory(MEMORY_SIZE){}
            int memory_size() {return memory.size();}
    };
    
    int main() {
        Clazz c;
        std::cout << c.memory_size() << std::endl;
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Model that named word. this is my word model public class
I have a model named Domain which looks like this: class Domain(models.Model): Model for
If I have a model named Client and controller that looks like this class
I have one grails application.In that I have one model class named Book. From
I have a such model named Foo: class Foo(models.Model): name = models.CharField() entry =
So, say I have models like this: class Foo(Model): name = CharField(max_length=200) def latest_comment(self):
I have a model named Promotion . class Promotion < ActiveRecord::Base; FORMATS = [0,1]
In one namespace (Ventosa.Graphics) I have a public class named Model namespace Ventosa.Graphics {
I have this class: class Contract(db.Model): book_number = db.IntegerProperty(required = True) initial_page = db.IntegerProperty(required
I have the following schema for the generation of a table/model class named Account

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.