Missing type specifier & unknown rewrite specifier (puzzle)

Source: Internet
Author: User


The code is as follows:

#pragma once

#include <string>

class PCB {public

:
    double pid;
    Double runtime;
    int priority;
    String state;//(Waiting, ready_a, running, Terminate, BLOCK_A) (ready_s, block_s)
    //pcb* next;
    pcb* Pre;
    static int ready;   Number of Ready queue processes
    static int exmem;   External memory process number
    static int POOL;    Number of fallback queue processes
    static int timestamp;//timestamp

    pcb () {/*next = this;*/}

    PCB (double rt, int pri): runtime (RT), Prio Rity (PRI) {
        pid = TIMESTAMP;
        state = "Waiting";
    }

};

int PCB::P ool = 0;
int pcb::ready = 0;
int pcb::exmem = 0;
int pcb::timestamp = 0;

After long-term inspection →. →, because there is no using namespace std,string is std ~~~~/vomiting blood + sigh
Also, notice how the class static variables are initialized.
Every experiment on a variety of vomit, this is afraid of the wrong, this is not fine of the * *, sweat sweat sweat shame.

Attached reprint true · An unknown rewrite specifier causes the problem:

1. Circular references
In separate compilation, we tend to write different classes or functions separately in different functions, improve work efficiency. However, if two classes are written in two different files when they are used, and they are referenced to each other, a circular reference will be thrown to raise this error.
Solution: the predecessor declaration.

2. Syntax errors
This problem is mostly caused by carelessness, such as a semicolon in a member function, and a Chinese semicolon, and such an error will occur.
Solution: Modify the semicolon

3. Sequence errors for classes
If a member of a class contains another class, the life of the contained class must precede the containing class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.