-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_Delete.cpp
More file actions
42 lines (34 loc) · 863 Bytes
/
Copy pathnew_Delete.cpp
File metadata and controls
42 lines (34 loc) · 863 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
/* new and delete keyword
"new" keyword used for creating new datatype or object
"delete" keyword used for deleting dynamically created variables and objects
*/
//creating new variable dynamically
int *var1 = new int; // *var1 is static pointer variable and "new" return address of dynamically created int block
float *num = new float; //creating float variable
int *arr = new int[5]; //creating array
class complex
{
private:
int a;
public:
//some method goes here
};
class student
{
private:
int name;
int roll;
public:
//some method goes here
};
int main(int argc, char const *argv[])
{
student *s1 = new student; //creating object
complex *c1 = new complex; //creating objects
cout<<"hello world";
return 0;
}