{"id":449,"date":"2023-02-12T02:30:31","date_gmt":"2023-02-12T02:30:31","guid":{"rendered":"https:\/\/aipsacademy.com\/blogs\/?p=449"},"modified":"2023-02-12T02:30:33","modified_gmt":"2023-02-12T02:30:33","slug":"class-and-object-in-c-programming-best-concept","status":"publish","type":"post","link":"https:\/\/aipsacademy.com\/blogs\/2023\/02\/12\/class-and-object-in-c-programming-best-concept\/","title":{"rendered":"Class and Object in C++ Programming Best concept"},"content":{"rendered":"\n<p><strong>There are different ways to make a program using class and object in&nbsp;<\/strong><a href=\"https:\/\/www.nipsacademy.com\/blogs\/c-programming-language-tutorial\/\"><strong>C++<\/strong><\/a><strong>. In this, we will learn how to use&nbsp;<\/strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/C%2B%2B_classes#:~:text=A%20class%20in%20C%2B%2B,a%20C%2B%2B%20class%20is%20private.\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>class&nbsp;<\/strong><\/a><strong>object&nbsp;<\/strong><a href=\"https:\/\/www.nipsacademy.com\/blogs\/c-programming-language-tutorial\/\"><strong>program<\/strong><\/a><strong>&nbsp;in very easy way. We can make a program using class in four ways like.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>One member function in the class definition<\/strong><\/li><li><strong>One member function outside the class definition<\/strong><\/li><li><strong>Multiple member functions inside the class definition<\/strong><\/li><li><strong>Multiple member functions outside the class definition<\/strong><\/li><\/ul>\n\n\n\n<p><strong>Q. Write a program to find sum of two numbers using class.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code language-cpp line-numbers\"><code>#include&lt;iostream.h>\r\n#include&lt;conio.h>\r\nclass nips\r\n{\t\t\r\npublic:\r\nint a,b,c;\r\nvoid show()\r\n{\r\na=10;\r\nb=5;\r\nc=a+b;\r\ncout&lt;&lt;\"Sum=\"&lt;&lt;c;\r\n}\r\n};\r\n\r\nvoid main()\r\n{\r\nclrscr();\r\nnips n1;\r\nn1.show();\r\ngetch();\r\n}\r\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><strong><\/strong><\/p>\n\n\n\n<p><strong>Sum=15<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are different ways to make a program using class and object in&nbsp;C++. In this, we will learn how to use&nbsp;class&nbsp;object&nbsp;program&nbsp;in very easy way. We can make a program using class in four ways like. One member function in the class definition One member function outside the class definition Multiple member functions inside the class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3,9,8],"tags":[],"class_list":["post-449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-12th-computer-science","category-bca","category-cbse-12th-computer-science","category-jac-12th-computer-science"],"_links":{"self":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts\/449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/comments?post=449"}],"version-history":[{"count":1,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts\/449\/revisions"}],"predecessor-version":[{"id":451,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts\/449\/revisions\/451"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/media\/450"}],"wp:attachment":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/media?parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/categories?post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/tags?post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}