Computer Programming
C Programming
C++ Programming

Can you declare a method within a method in c or c plus plus?

Top Answer
User Avatar
Wiki User
Answered 2011-08-30 07:34:05

C: there are no methods in C.

C++: no.

User Avatar

Your Answer

Related Questions

The this operator in C++ is a compiler generated pointer to the instance of an object, accessible from within a method of that object.

Overriding in C++ is when a method of a base class is "replaced", so to speak, in a derived class with a method of the same name, type, and parameters. In order for this to be possible, the base class must declare the method either protected or public. The base class' version of the method will be used for instances of the base class, while the derived class' version of the method will be used for instances of the derived class.

In C++, methods are simply class member functions.

No., If you want to declare you jus use _ in between so the declaration will be like int seg_no;

public is an access-modifier that allows you to access methods or properties of a class from outside of the class. A method or property set to protected can only be accessed from within the creating class or subclasses, while a private method or property can only be accessed from within that class

In C++ all names (including variables) must be declared before they can be used.

No. But you can override it. A default destructor is provided even if you don't declare one.

Yes, you can declare a private class within another class. The internal class is effectively invisible to all classes and functions outwith the external class members.

In C++, a static class member is common to all instances of that class. A static class method is a method that can only access static class members. Non static methods can also access static members, but remember that there is only one instance of that member amongst all instances of the class. One advantage of a static method is that you do not have to instantiate the class to use the static member or static method.

#define is a preprocessor directive used to declare macros. typedef is a C++ keyword to define a data type.

The definition of the structure in C is limited to within the module and cannot be initialized outside its scope. Where as in C++ you can initialize the objects anywhere within the boundaries of the project.

The assignment operator. If you do not declare one in your class, the compiler generates one for you.

See related link. It's in C rather than C++, but conversion to C++ is fairly simple.

No. Keywords are reserved and cannot be used as identifiers. However, C/C++ is case-sensitive. So although register is a reserved keyword, Register is not.

Declare the type (int, char, double, etc) followed by the name of the variable. The variable name is a reference to the memory allocated to the type being declared. If the variable is a pointer to the type, precede the name with *. In C++, you may also initialise variables in the declaration.

The need to declare header files is not compulsory in C++. You may place all your code in a single source file if you so desire. However, header files are useful in that they separate interface from implementation and aid in hiding information.

Virtual method invocation is a term borrowed from C++. It means that methods are invoked polymorphically. Instead of invoking the method in the compile-time type, the method is invoked as its runtime type. In C++, you declare methods virtual that are executed this way.

In C++, overriding and function, method, or operator is a different thing than (dynamic) polymorphism, so overriding a polymorphic method is almost entirely possible.

Yes. You need a library, such as Oracle Pro*C to do that. Depending on your requirements and/or desires, you can use the native (OCI) method, or you can use the imbedded (precompiler) method.

A private member can only be accessed from within a method of the class.(Not 100% certain what the question means. If this answer is not sufficient, please restate the question, giving more details as to what is being asked.)

If you declare a variable inside of any fuction (except main) it will not be available to other functions.

A "method" is what Java calls its procedures. C++ has only functions (which return a value) and subroutines (which do not return a value).

C++ allows any combination of structured programming, procedural programming, object-oriented programming and template metaprogramming.

Copyright ยฉ 2021 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.