-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEX-13-Class-Object.dart
47 lines (34 loc) · 1.12 KB
/
EX-13-Class-Object.dart
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
42
43
44
45
46
47
/*
class class_name {
// Body of class
}
Class is the keyword use to initialse the class.
class_name is the name of the class.
Body of class consists of fields, constructors, getter and setter methods, etc..
Declaring objects in Dart –
Objects are the instance of the class and they are declared by using new keyword followed by the class name.
var object_name = new class_name([ arguments ]);
In the above syntax:
new is the keyword use to declare the instance of the class
object_name is the name of the object and its nameing is similar to variable name in dart.
class_name is the name of the class whose instance variable is been created.
arguments are the input which are needed to be pass if we are willing to call a constructor.
*/
//////// Example --------1 /////////////////
class Student {
var stdName;
var stdAge;
var stdRoll;
showStdInfo() {
print("Student Name is $stdName");
print("Student Age is $stdAge");
print("Student Roll Number is $stdRoll");
}
}
void main() {
var std = new Student();
std.stdName = "Sanjoy Biswas";
std.stdAge = 23;
std.stdRoll = 32;
std.showStdInfo();
}