answersLogoWhite

0


Best Answer

A forward declaration. However forward declarations can only be used when the class is used as a pointer or reference prior to its definition, otherwise it must be defined before it is used.

class A; // forward declaration

class B {

A& data; // reference to class that has yet to be defined

};

class A {}; // definition

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

use this statement:

class specific_class;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In c plus plus Who tells the compiler that a specific class will be declared later in the program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can a method be declared in any order in a class?

Yes. There is no specific order in which the compiler expects methods to be present. As long as the method is inside the class it is perfectly fine.


What happens if a class doesn't implement all the methods defined in the interface?

It depends on how the class is declared.If the class is a normal class - Then the compiler will complain. All the methods in an interface must be implemented by the class to successfully compile the classIf the class is declared as abstract - Then the compiler will ignore the fact that a few methods are not implemented


What happens if a constructor is not defined in class?

Nothing happens. The compiler successfully compiles the class. When a class does not have a specific constructor, the compiler places a default no argument construtor in the class and allows you to compile and execute the class. public class Test { } and public class Test { public Test(){ } } are one and the same.


Is java interpreter or compiler?

Java has both a compiled and an interpreted stage.1) The programmer writes his source codes (.java extension); a compiler will compile this to bytecode (.class extension).2) When the end-user runs the .class program, the JVM (Java Virtual Machine) will interpret this.


What do you get when you compile a java program?

The java interpreter or JVM (Java Virtual Machine) is not able to execute the java source code for a program. The java source code first needs to be compiled into bytecode that can be processed by JVM. Producing bytecode make the program platform independent as each platform has its own JVM. It is also possible to directly write bytecode, bypassing the need to compile, but that would be tedious job and also not good for security purpose as the compiler checks for various errors in a program.

Related questions

Can Methods be declared in any order in a class.?

Yes. There is no specific order in which the compiler expects methods to be present. As long as the method is inside the class it is perfectly fine.


Can a method be declared in any order in a class?

Yes. There is no specific order in which the compiler expects methods to be present. As long as the method is inside the class it is perfectly fine.


What happens if a class doesn't implement all the methods defined in the interface?

It depends on how the class is declared.If the class is a normal class - Then the compiler will complain. All the methods in an interface must be implemented by the class to successfully compile the classIf the class is declared as abstract - Then the compiler will ignore the fact that a few methods are not implemented


What happens if a constructor is defined in class?

Nothing happens. The compiler successfully compiles the class. When a class does not have a specific constructor, the compiler places a default no argument construtor in the class and allows you to compile and execute the class. public class Test { } and public class Test { public Test(){ } } are one and the same.


What happens if a constructor is not defined in class?

Nothing happens. The compiler successfully compiles the class. When a class does not have a specific constructor, the compiler places a default no argument construtor in the class and allows you to compile and execute the class. public class Test { } and public class Test { public Test(){ } } are one and the same.


What happens when no constructor function is declared in a class - in Java?

When any constructor is deffined in your class, the java compiler create a default no argument constructor for you. This constructor only have an invocation to the super class constructor (" super( ) ").


Is java interpreter or compiler?

Java has both a compiled and an interpreted stage.1) The programmer writes his source codes (.java extension); a compiler will compile this to bytecode (.class extension).2) When the end-user runs the .class program, the JVM (Java Virtual Machine) will interpret this.


What do you get when you compile a java program?

The java interpreter or JVM (Java Virtual Machine) is not able to execute the java source code for a program. The java source code first needs to be compiled into bytecode that can be processed by JVM. Producing bytecode make the program platform independent as each platform has its own JVM. It is also possible to directly write bytecode, bypassing the need to compile, but that would be tedious job and also not good for security purpose as the compiler checks for various errors in a program.


What is mean final class and final variable?

A final variable cannot have its value changed. It is used to define a constant. Assigning a value to a final variable after it is declared will cause a compiler error. A final class cannot be sub-classed. It is used to prevent rogue programmers from sub-classing your classes and changing their behavior. Trying to extend a final class will cause a compiler error.


Can you have multiple main method in the same class?

according to my knowledge it is no a main can have multiple classes but a class cannot have multiple mains...main indicates the beginning of a program and if we have n number of mains then the compiler will show an error in all the main program that we write


When java uses compiler?

What i know is java we will use compiler when it want to get class file(file with .class extension) from java file(file with .java extension).


Difference Between interpreter and compiler in java application?

Due to platform independence, a Java compiler will interpret Java source code into Java Byte Code and pass to the JVM, which will pass machine understandable code through to cpu. (clarification needed).A conventional compiler converts source code directly to machine code.(clarification needed).