illegal function?

There is a function that prints a value in the second constructor of class Time:
1
2
3
4
5
6
		Time(int alpha, int omega)
		{
			int result = alpha * omega;
			std::cout<<result;
		}
 

Is this illegal to perform functions within a constructor?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>

	class Time{

	private:
		int alpha;
		int omega;
	public:
		Time()
		{
			omega = 4;
		}

		Time(int alpha, int omega)
		{
			int result = alpha * omega;
			std::cout<<result;
		}

	};

	int main()
	{
		//Time time(3,5);			//direct initialization
		Time time{37,5};			//uniform initialization as well

		return 0;
	}



no error
Is this illegal to perform functions within a constructor?
No, calling functions within constructors is permissible.
Topic archived. No new replies allowed.