Free Essay

Oop Concepts

In:

Submitted By sufyan92
Words 482
Pages 2
www.kbcafe.com

OOP Concepts by Example by Randy Charles Morin Of late, I have been writing very narrow focused articles that explain how to accomplish this or that task. Many of you have changed your questions from the narrow focus of how-to questions to broader theorectical questions. One question I got lately that intrigue me was to explain the concepts of OOPs showing C++ examples. Let's start by laying down some ground work. I assume that you are familar with the following OOP concepts; classes, objects, attributes, methods, types. If not, then this article might not be in your realm. I'd suggest starting with the basic concepts of C++ before you attempt to understand the more indepth concepts that I'll be discussing in this article. When we speak of OOP concepts, the conversation usually revolves around encapsulation, inheritance and polymorphism. This is what I will attempt to describe in this article.

Inheritance
Let us start by defining inheritnace. A very good website for finding computer science definitions is http://www.whatis.com. The definitions in this article are stolen from that website. Definition: Inheritance Inheritance is the concept that when a class of object is defined, any subclass that is defined can inherit the definitions of one or more general classes. This means for the programmer that an object in a subclass need not carry its own definition of data and methods that are generic to the class (or classes) of which it is a part. This not only speeds up program development; it also ensures an inherent validity to the defined subclass object (what works and is consistent about the class will also work for the subclass). The simple example in C++ is having a class that inherits a data member from its parent class. class A { public: integer d; }; class B : public A { public: };

The class B in the example does not have any direct data member does it? Yes, it does. It inherits the data member d from class A. When one class inherits from another, it acquires all of its methods and data. We can then instantiate an object of class B and call into that data member. void func() { B b; b.d = 10; };

Copyright 2001-2002 Randy Charles Morin

www.kbcafe.com

Polymorphism
Inheritance is a very easy concept to understand. Polymorphism on the other hand is much harder. Polymorphism is about an objects ability to provide context when methods or operators are called on the object. Definition: Polymorphism In object-oriented programming, polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning to a particular symbol or "operator" in different contexts. The simple example is two classes that inherit from a common parent and implement the same virtual method. class A { public: virtual void f()=0; }; class B { public: virtual void f() {std::cout

Similar Documents

Free Essay

Oop Concepts with Real Life Example and Codes

...OOPS Concept with Real-world example Introduction OOP is Nothing but Object Oriented Programming.According to Wikipedia,  Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs. OOPs have following features 1. Object   - Instance of class 2. Class    - Blue print of Object  3. encapsulation  - Protecting our data 4. polymorphism   - Different behaviors at diff. instances 5. abstraction    - Hidding our irrelavance data 6. inheritence    - one property of object is aquring to another property of object 1. Object Basically an object is anything that is identifiable as an single material item. You can see around and find many objects like Camera, Monitor, Laptop etc. In OOP perspective, an object is nothing but an instance of a class that contains real values instead of variables 2. Class A class is a template definition of the methods and variables for a particular kind of object. In other words, class is the blue print from which an individual objects are created. every human has eye ,so eyecolor can be considered as the property of human being which can be encapsulted as a data in our class Human class Human {     private:     EyeColor IColor;     NAME personname; }; Consider object of class of                 Human myhuman; we want set myhuman's name as "linto" and IColor as "black", For that we want methods to do that task. So need methods...

Words: 1017 - Pages: 5

Premium Essay

Theories

...researching the information that you have provided. Behaviorism (grand theory) The theory that I chose was behaviorism. Behaviorism is a grand theory of the human development and studies the observation of behavior. This theory is also a learning theory it explains the laws and the process as to how people learn to behave. According to John Watson, “if psychologists can focus on behavior, they will realize that everything can be learned.” I can apply this theory to several concepts as it relates to my Christian worldview. The first concept is prayer; the very first prayer that is learned is The Lord’s Prayer. Through behavior you learned this either listening to someone recite this prayer or you learned it by reading the bible. The second concept is worship. Worship is first learned and then through maturity you develop your own sense of worship. Worship is learned at home by parents or those whom you live with or it’s learned at your church by those who you attend worship service with. The last concept is praise. Praise just like worship is a very important part of my worldviews. Praise is a learned behavior because it teaches you how to give honor to God. Again just like worship this is learned through watching those who worship. Behaviorism can...

Words: 345 - Pages: 2

Premium Essay

Young Children

...children’s conceptions change during the instructional process and how the social discussion during the experimental exploration can be seen in terms of the cognitive changes in children. Young children’s conceptual change has not been as widely studied as that in older students. The researcher in this case study suggested that conceptual changes as a party of the learning process should be viewed as a life long process, which begins before children enter school. Six-year-old children undergo floating and sinking during their conceptual change process. This article attempted to describe this process and how social discourse during the process of knowledge construction is linked to the change in children’s concepts. Conceptual change had generally been examined only through cognitive functions as a general process without consideration of the context before this case study. The children that were selected for this study were pre-schoolers age six. They all hailed from the city of Joensuu, Finland and were from the kindergarten involved with the ESKO research project. The groups wanted to participate in the study, but the researchers taught the topic after the teachers disagreed. The children came from two different groups in the kindergarten with mixed genders. The research was conducted into three parts: pre-interview, instructional process, and post-interview. The pre-interview consisted of two parts that aimed...

Words: 502 - Pages: 3

Free Essay

Belonging Essay

...Alienation is a key theme in Peter Skryznecki’s Migrant Hostel and Tim Winton’s Neighbours. The authors use techniques to engage the reader and to teach the responder about alienation and how it affects people. Skryznecki uses symbolism to convey that migrants were alienated from Australian society. Skryznecki says "barrier at the main gate" to emphasize how the migrants were excluded from the outside world. The "barrier" is both literal and symbolic. It is symbolic of the barrier to belonging in Australia, and the alienation of migrants. Skryznecki uses similes to reiterate his point that migrants were alienated. He say "like a homing pigeon" to compare migrants to birds. He does this to show that the migrants don't belong the are constantly moving to survive like birds do. He further develops this idea through a second simile "like birds of passage". He is explaining that nothing was certain, and there was no security or place of belonging. The migrants feel alienated and want to belong but the Migrant hostel won't let them, they are being forced into alienation. Skryznecki uses similes to convey his thematic concern of alienation. Perceptions and ideas of belonging, and of not belonging, vary. There is no definite truth to where someone belongs. A person can belong somewhere different to where they are assumed to belong. and can not be forced on someone. People belong to different groups than others. Perceptions of belonging are shaped by personal, cultural and social...

Words: 385 - Pages: 2

Free Essay

Speech - Gwen Harwood - Loss

...loved ones, which can be valued by contemporary audiences today due to it being an issue that is faced by everybody in their life at some point. When a loved one is no longer part of an individual’s life, one may experience grief and as a result realise the role and importance of that loved one. From my perspective, Harwood presents the concept of loss of loved ones through MWGML with the euphemism “You left the world so”, which highlights that her mother was not only a loss to her life but also a loss to the world, suggesting that she had great value and respect for her mother. There is a similar significance placed on her mother’s life that is stressed with the use of alliteration in “lived nearly thirty thousand days”. This presents the idea that she lived daily as a mother contributing to the lives of her children. Harwood also introduces a cloth motif in her poem, through the line “when she died she was folding a little towel” to highlight the importance of her day to day life. Harwood then sustains this motif later in her poem with “a fabric of marvels”. This motif, combined with “lived nearly thirty thousand days”, reinforces the concept that every day of her life was important. Also through the use of the...

Words: 854 - Pages: 4

Free Essay

Management

...Cares is currently operating with positive margins based on this goodwill concept. Research shows that while some people cannot pay much or nothing at all, others that can afford to pay typically pay more (Ron Shaich, 2012). Panera Cares illustrates that business models do not always need to follow conventional management concepts. This concept is gaining recognition in the business world, local communities and also challenges other corporations to review their business models and strategies with consideration to the community and people that make them successful. Introduction Panera Bread has decided to take action regarding the slumping economy that has caused many Americans to go hungry. According to the US Department of Agriculture, last year, 17.2 million households faced food insecurity (Martin, 2012). The result of this growing epidemic is Panera Cares, a restaurant cafe where people can eat nutritious food in the same uplifting environment Panera is known for and pay whatever they can afford (Ron Shaich, 2012). Food insecurity in our country is the major concern of Panera Cares and is the heart of the company vision. A menu is available with a slight twist, no prices only suggestions; customers are encouraged to pay whatever they like. Each community cafe is self-sustaining; showcasing the common good in people to do the right thing. The business concept was created with the intent to build a partnership with the community and...

Words: 1397 - Pages: 6

Premium Essay

Polarity

...include: stability and change, individual and team, long and short term, autocratic and participatory and my topic, cost and quality. Any of these pairs are known to counter the other. In my case, it is important to note that when quality improves, cost generally increases and vice versa. Throughout this paper I will discuss managerial approaches to utilize these two concepts to your advantage without ever overlooking either of them. It is important to embrace the fact that there are polarities everywhere we turn and instead of trying to fight against them, we should develop their concepts to make us more complete. Larry Hirschhorn has argued that in order for managers to become proficient in managing polarities, they must develop a set of “rules of thumb” for when they encounter different circumstances. They establish these rules with the hopes of somewhat standardizing their way of thinking as well as how to allocate resources for each instance. The guidelines are generally developed to recognize patterns and opportunities. Hirschhorn recommends managers create a 2 x 2 table to help illustrate this concept and to categorize its different states. Each axis would include a “hi” and “lo” status with the top right box representing the “Hi-Hi” state. The “Hi-Hi” state would represent the situation which required the expert’s immediate attention (Hirschhorn, 2001, p. 12) Below is an example of a polarity map for my argument. Competitive Advantage Goods are manufactured...

Words: 856 - Pages: 4

Premium Essay

Theory Accounting and Practices

...In the 1980s the usefulness of the FASB’s Conceptual Framework was soon questioned. Indeed, many researchers have pointed out the incompleteness, the inconsistency, the circular reasoning and non-operationality of the American Framework (Dopuch and Sundern, 1980; Solomons, 1986; Gerboth, 1987; Hines, 1989). Moreover, the decision-useful objective didn’t gather real support when the FASB carried out a survey to determine if constituencies did agree with the Trueblood report objectives of financial reporting (Dopuch and Sunder, 1980). Notwithstanding these issues, the FASB and the IASB go further towards a focus on capital providers needs in their joint project of revision of the Conceptual Framework when writing that financial reporting is not primarily directed to other groups than capital providers. There is a possibility that the objectives assigned to financial accounting as a social activity is directed by a dominant group that imposes its will on all others involved in the activity by making its own objective become the objective of the social activity (Dopuch and Sunder, 1980). Therefore, when criteria are used to justify the identification of primary users, there should be a comprehensive analysis of their definition, their importance for each category of users of financial reporting and if other criteria should be taken into account before reaching strong structuring conclusions on the objective of financial reporting and on identifying their primary users...

Words: 430 - Pages: 2

Premium Essay

Note Taking

...remembering specific details from classroom lectures without good notes. These note taking strategies will help you to take better notes: ▪ Make clear and accurate notes Make sure to take legible and accurate notes since it is not uncommon to forget key details discussed in class after it has ended. Frequently, students comprehend the teacher's lecture, so they'll neglect to jot down specific details only to forget them later. Students who keep accurate notes can review them later to fully grasp key concepts during personal study time. Additionally, since during classroom lectures teachers frequently cover many topics, effective notes enable students to concentrate on specific topics. ▪ Come to class prepared Students properly prepared for class usually take better notes. Proper preparation includes completing assigned reading prior to class and reviewing notes from previous lectures. Students who do this can ask questions about confusing concepts and be prepared for new topics. ▪ Compare your notes To ensure your notes are as accurate and detailed as possible, compare them with the notes of other students after class is over. This is useful because your colleagues will frequently write down lecture details that you forgot or missed. This strategy will make classroom notes more thorough and precise. ▪ Minimize distractions Effective note takers avoid classroom distractions. This can include sitting in spots with fewer distractions and...

Words: 602 - Pages: 3

Free Essay

Hero Concept in Literature

...Writing Assignment 2: Hero Concept In literature there are many different concepts that authors use, one concept that is used is the 'hero concept,' which can capture any audience, and can be seen in many different ways, but it's pretty clear that a hero is someone with the will to stand up for what they believe in, has courage, and is strong for others. People in general, at some point, have wanted to be the hero, or have the courage to stand up for what they believe in. More often than not, people stand by and don't act in a heroic manner, so when reading a story, poem, or other piece of literature that uses the hero concept; it captures the reader and keeps the reader interested. The hero concept is clearly used in "Bodega Dreams," "Hard Rock Returns to Prison for the Criminal Insane," and "The Train from Hate." The authors of these pieces of literature keep the reader captivated by using the hero concept, and the pathos appeal, evoking a sense of emotion in the reader. "Bodega Dreams" by Ernesto Quinonez has a great example of a hero. This short story is of a class of apparent minority students, who are told by one teacher that they will never amount to anything, and would end up in jail or on the streets. Since the students are being constantly told that they will fail, they don't make an effort. This causes another teacher, the "hero," to become very angry, because he wants to see his students succeed. The narrator reveals this teachers heroic nature when the teacher...

Words: 1030 - Pages: 5

Free Essay

Language Acquisition

...their practices is complex and context dependent. There is an argument about the relationship of teachers’ beliefs and practices and to find out frameworks of understanding the consistency and inconsistency of teachers’ beliefs and knowledge. There are different views about the concept of belief, depending on the point of view of the theorist or researcher. According to Mansour (2009), beliefs are one of the most difficult concepts to define. Although educational literature has paid great attention to teachers‟ beliefs, there is still no clear definition of belief (Savasci-Acikalin, 2009). As Pajares (1992) argued, “the difficulty in studying teachers‟ beliefs has been caused by definitional problems, poor conceptualizations, and differing understandings of beliefs and belief structures” (p. 307). Therefore, the definitions of beliefs have been varied in the literature. He suggested that researchers need agreement on meaning and conceptualization of belief. Dewey (1938) developed a bipolar model within which there were two opposite dimensions: on the one pole, beliefs were characterized as traditional, and on the other as progressive. These two poles formed a uni-dimensional system, since the concept of belief consisted of traditional and progressive components which were negatively related. Thus, a person oriented at the traditional pole would be expected to disagree with progressive ideas and vice versa. In an attempt to...

Words: 536 - Pages: 3

Premium Essay

Management

...a brand, product or service utilizing traditional marketing placement strategies (i.e. price, promotion, distribution, packaging, and competition). Positioning is also defined as the way by which the marketers attempt to create a distinct impression in the customer's mind. Positioning is a concept in marketing which was first introduced by Jack Trout ( "Industrial Marketing" Magazine- June/1969) and then popularized by Al Ries and Jack Trout in their bestseller book "Positioning - The Battle for Your Mind." (McGraw-Hill 1981) This differs slightly from the context in which the term was first published in 1969 by Jack Trout in the paper "Positioning" is a game people play in today’s me-too market place" in the publication Industrial Marketing, in which the case is made that the typical consumer is overwhelmed with unwanted advertising, and has a natural tendency to discard all information that does not immediately find a comfortable (and empty) slot in the consumers mind. It was then expanded into their ground-breaking first book, "Positioning: The Battle for Your Mind," in which they define Positioning as "an organized system for finding a window in the mind. It is based on the concept that communication can only take place at the right time and under the right circumstances" (p. 19 of 2001 paperback edition). What most will agree on is that Positioning is something (perception) that happens in the minds of the target market. It is the aggregate perception the market has of...

Words: 627 - Pages: 3

Premium Essay

Starbuck Case Study

...Unit IV Case Study Toni K Bonton Columbia Southern University During the concept stage of research, Starbucks set out to test the idea of a card that utilized dual-functionality versus using two separate cards (Cooper & Schindler, 2011). To do this, online focus groups were used to determine customer preferences. Not only did this type of study measure how well customers understood the dual-functionality aspect of the proposed card and what concepts needed to be explained further, but it also revealed customer appeal to the card and its features (Cooper & Schindler, 2011). The product optimization study was another online study conducted during the concept stage to determine the impact certain features have on a customer's decision to apply for the card and which of those features could potentially increase sales (Cooper & Schindler, 2011). This information proves beneficial in knowing which customers would not apply for the card and why and how the most appealing features would affect the profit margin. In the final stage of research, Starbucks measured the return on their marketing investment, using customer feedback obtained through yet another online survey after their new card was launched (Cooper & Schindler, 2011) . The customer feedback responded to customer awareness and the reasons why customers chose to apply, or not apply, for the card. This type of study measured the success of the card launch and how that success came about, along with whether or...

Words: 744 - Pages: 3

Premium Essay

Competencies Assessment

...| Competencies Assessment | Submitted for MBA 602 | | | Submitted on June 30th 2013 | | This survey taught me a lot about my perception of the government’s role, and the importance government regulation has when it comes to the medical industry. I scored with the majority of the students when it came to describing the roles of biostatics serves in the discipline of public health. I found it to be of low/medium importance level. I do feel there is a need for biostatistics however; it is one of the concepts that does not play in my mind on a daily basis and it seems like most of the other students would agree. It tends to only strike me as important when it is on a national, worldwide, or has gained the importance of the media or news. I also scored with the majority of the class when it came to the statistical concepts as well. I do feel that averages and statically concepts can be very helpful when it comes to the impact that things health wise can have on the human population. When it comes to statistic the number can be manipulated pretty easily to portray whatever picture that people want. That does not mean is what is always being done, but I think is a large reason why as a class we generally find a low importance on it. For example, drug companies do a great job using statistics to show how great their products are with helping the world’s health problems. What the drug companies do not rave about is the other side effects their new medication cause to...

Words: 817 - Pages: 4

Premium Essay

Concept Analysis

...Concept Analysis Assignment Grand Canyon University Theoretical Foundations for Nursing Roles and Practice NUR 502 Ms. Maria Mendez June 13, 2013 Concept Analysis Assignment Today’s nursing profession encompasses a variety of specialties and disciplines that demonstrate a wide range of phenomena. According to McEwin and Willis, in clinical practice, those phenomenon that are frequently seen aid advanced practice nurses in developing interventions and clinical protocols because they are said to be stable and reliable components of the practical nursing experience (McEwin & Willis, 2011, p. 47). The observed phenomena may or may not have had research studies associated with them in the past to concretely define them, and therefore the notion of concept development and analysis arose to clarify the meanings of the phenomena encountered in one’s practical setting. McEwin and Ellis define concepts as “terms that refer to phenomena that occur in nature and thought” (McEwin & Willis, 2011, p. 47). Furthermore, concepts can be concrete, nonconcrete, variable, and non-variable in manner and described in words or phrases. Concept analysis is utilized to clarify vague concepts in nursing that may be overused and unclear and also to promote a mutual understanding amongst colleagues (Falan, 2010). For the purpose of this assignment, an article found in the Scandinavian Journal of Caring Sciences regarding the concept of abuse in healthcare was selected for concept analysis...

Words: 1242 - Pages: 5