answersLogoWhite

0

Classes cannot return values, only functions can return values. But you cannot return a function from a function, you can only return a function pointer -- a pointer variable holding the address of the function you wish to return. All possible return values must be of the same type, therefore all function signatures and return types must be exactly the same -- only the name of the functions can differ.

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

What is main advantage of using constructors in java?

Constructors have the same name as the class itself and they do not specify a return type, not even void because they return the instance of the class itself. Because constructors have the same name as the class then they allow method overloading and also save memory and execution time of program. Program release memory of constructors function after using this function and it reduce program complexity.


How to write C plus plus Program to take 2 distant values as argument and return the larger value on the screen?

Use the following template function: template<class T> T& max(T& x, T& y){return(y<x?x:y;}


Write a java program of addition of two variables?

public class AddNumbers{ public int add(int a, int b){ return a + b; } }


Write a program to find the grade obtained by the students of a class using structure?

Write a program to find the grade obtained by the students of a class


What are the advantages of having program in a class in C plus plus?

You don't write programs in a class in C++, you write programs that use classes. Every C++ has at least one function, main, the entry point of the application. You define the classes and functions that are used by your main function. Classes allow you to classify the objects used by your program, allowing data to be manipulated in a highly controlled manner, ensuring consistency and robustness throughout your program.


Write down a program with Passing object to friend function?

Here's a simple example of a C++ program that demonstrates passing an object to a friend function: #include <iostream> using namespace std; class Box { private: int length; public: Box(int len) : length(len) {} friend void printLength(Box b); // Friend function declaration }; void printLength(Box b) { // Friend function definition cout << "Length of box: " << b.length << endl; } int main() { Box box(10); printLength(box); // Passing object to friend function return 0; } In this program, the printLength function is declared as a friend of the Box class, allowing it to access the private member length.


How do you write a binomial distribution table in C program?

Class&genus


Write c plus plus program for new and delete operator using class?

#include<iostream> class foo{ int m_data; }; int main() { foo* p=new foo; delete( foo), foo=NULL; return(0); }


When you make a c program in c language then how many types class are required?

It depends on what you mean by 'types class'. Here is the shortest C program, without any 'types class': int main (void) { return 0; }


Program to find biggest number among two numbers using template function?

template<class T> T& max(const T& x, const T&y){return(x>y?x:y); }


Write a program to display the name of days when a user enters a number?

write a program to display your name age class schoolname e-mail 2hobby based on choice


True or False A C plus plus class constructor cannot return a function value?

True - A C++ constructor cannot return a value.